looping through a database
| From: | Richard Kurth | Date: | Mon, 16 Jun 2008 20:57:49 +0000 |
| Subject: | looping through a database | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-275453@lists.php.net to get a copy of this message | ||
I am looping through a database of files that are numbers 1 through 10 if number 1 is in the database I what to print out the first table below if it is not then print the else section below. Then loop through the database to see if 2 through 10 are there and do the same thing. Of course what I am doing does not work. Should I move it all to an array and then loop through it. Or use a foreach loop.
Could you please give me an idea where to start looking
while($row=mysql_fetch_array($sql_result)){
if ($row["number"]==1) {
<tr>
<td> File 1</td>
<td>This is the file</td>
<td>Delete</td>
</tr>
}else{
<tr>
<td>File1</td>
<td></td>
<td>Add</td>
</tr>
}
}