Jump to content

Another logic problem


lc21

Recommended Posts

hi, I am currently displaying data from a database as follows, however I would like to be able to add another column to the table which displays  a button so a user can download a file that is related to that record, however there is not always a file available which is indicated in the database as either yes or no. If it is yes i would like the download link to be displayed in the new column as a button or left blank if no file has been uploaded.

 

I was just wondering how this could be done? thank you

 


<?php
while($display=mysql_fetch_array($query))
{
     echo "<tr><td>".$display['problemId']."</td><td>".$display['name']."</td></tr>";
}
?>
[/coded]

Link to comment
https://forums.phpfreaks.com/topic/60303-another-logic-problem/
Share on other sites

<?php
while($display=mysql_fetch_array($query))
{
     if (empty($display['problemFile'])) {
          $file = NULL;
     }
     else {
          $file = "<td>".$display['problemFile']."</td>";
     }
     
     echo "<tr><td>".$display['problemId']."</td><td>".$display['name']."</td>".$file."</tr>";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/60303-another-logic-problem/#findComment-299992
Share on other sites

<?php
while($display=mysql_fetch_array($query))
{
     if (empty($display['problemFile'])) {
          $file = NULL;
     }
     else {
          $file = "<td>".$display['problemFile']."</td>";
     }
     
     echo "<tr><td>".$display['problemId']."</td><td>".$display['name']."</td>".$file."</tr>";
}
?>

 

So what happens when some rows have a file, and some dont? Your table would not be valid html.

Link to comment
https://forums.phpfreaks.com/topic/60303-another-logic-problem/#findComment-300092
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.