Code not looping like planned
Posted: Tue Sep 26, 2006 4:58 pm
So I have 2 entries in a database, and I want each one displayed in a table. Here is the code I have, but it only display's the first entry and none of the ones that follow. Heres the code, I know its messy, but it is what it is:
Any idea why it wont repeat for each entry in the db and quits after it finds the first one?
Much thanks in advance.
Code: Select all
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<?php
$result = mysql_query("SELECT * FROM wall WHERE global_id='$_GET[id]'") or die(mysql_error());
$row_count = mysql_num_rows( $result );
if($row_count > 0) {
$initial_count = 0;
while($initial_count < $row_count)
{
?>
<tr>
<td width="16%" rowspan="3" valign="top"><div align="center">
<?php
$result = mysql_query("SELECT * FROM wall WHERE global_id='$_GET[id]'") or die(mysql_error());
$row = mysql_fetch_array( $result );
$message = $row['message'];
$to_id = $row['global_id'];
$from_id = $row['poster_global_id'];
$when = $row['when'];
$result = mysql_query("SELECT * FROM profile_photo WHERE global_id='$_GET[id]'") or die(mysql_error());
$row = mysql_fetch_array( $result );
$picture = $row['profile_photo_url'];
include('functions.php');
$scale = imageScale($picture, 50, -1);
$width = $scale[0];
$height = $scale[1];
echo "<img src=\"$picture\" width=\"$width\" height=\"$height\">";
?></div></td>
<td width="84%" style="border-top: 1px solid #3b5998; border-bottom: 1px solid #d8dfea; background: #f7f7f7;"><span class="style2">
<?php
$result = mysql_query("SELECT * FROM loginphp WHERE global_id='$from_id' ORDER BY id desc") or die(mysql_error());
$row = mysql_fetch_array( $result );
echo $row['Fname'];
echo " ";
echo $row['Lname'];
?></span>
<?php
echo " at " . $when . "";
?></td>
</tr>
<tr>
<td><?php echo $message; ?></td>
</tr>
<tr>
<td style="border-bottom: 1px solid #d8dfea;"> </td>
</tr>
<?php
$initial_count++;
}
} ?>
</table>Much thanks in advance.