Skip to content
Advertisement

php – html: Different data in each row of a the same column in a table

I want to make a cell’s data different in each row of the same column, according to the value of the $row[‘epilogh’]:

<tr>
    <td> <?php echo $row['id']; ?> </td>
    <td> <?php echo $row['epilogh']; ?> </td>
    <td> <?php echo $row['um_username']; ?> </td>
    <td> <?php echo $row['myrole'];?> </td>
    <td> <?php echo $row['request_date'];?> </td>

    <!-- i want the following 2 td to be one and work in the above different cases  -->
    <td style="max-width: 250px; text-align: center;">
    <?php echo '<a href="../make-solemn-declaration-pdf-sec/?id='.$row['id'].'" target="_blank">'.$row['id'].'</a>';?>
                                <form action="../make-solemn-declaration-pdf/?id=<?php echo $id; ?>" method="POST" target="_blank">
                                    <button type="submit" name="btn-pdf">Make a PDF</button>
    </form>
    </td>

    <td style="max-width: 250px">  
        <form method="POST" enctype="multipart/form-data" action="../upload-file/?id=<?php echo $row['id']; ?>">
            <input type="file" name="fileToUpload" id="fileToUpload" accept=".pdf" required />
            <br><hr>
            <input type="submit" name="submit" value="Upload" />
            <? echo "$pdf";?>
        </form>
    </td>

    <td> <a href="../pistop-delete/?id=<?php echo $row['id']; ?>">Delete</a> </td>
</tr>

So let’s say that if $row['epilogh'] is ‘A’ I want a form so a file could be uploaded. On the other hand when $row['epilogh'] is ‘B’ I want to have a link there for another page. How can I do this?

Advertisement

Answer

if i understand you correctly, you can do this: just use one td:

<td style="max-width: 250px;<?php if($row['epilogh'] == 'A')  echo 'text-align: center;' ?> ">
 <?php
   if($row['epilogh'] == 'A'){
     echo "your upload form"
   }
   else{
     echo "your link to another page"
   }
?>
</td>
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement