Home > Software engineering >  php - html: Different data in each row of a the same column in a table
php - html: Different data in each row of a the same column in a table

Time:11-21

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

                            <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 lets 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?

CodePudding user response:

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>

CodePudding user response:

Missing double quotes (") in style attribute

  • Related