Can someone tell me why in this code, the images are displayed and text displayed wrong. They appear like this:
Image1
Image 2 - Description of image 1
Image 3 - Description of image 2
<HTML>
<HEAD>
<TITLE>Project Pictures for <?php echo $table; ?></TITLE>
<BODY>
<div align="center"><font color="red"><h1>Project Pictures for <?php echo $table; ?></h1>
<TABLE WIDTH="100%">
<TR>
<TD>Pictures</TD><TD>Descriptions</TD><TD>Section</TD>
</TR>
<?php
extract($_GET);
extract($_REQUEST);
$user = "oprods";
$pass = "breakin";
$db = "pictures";
$table = $_REQUEST['table'];
for ($id = 1; $id <= 3; $id++ ) {
$conn = @mysql_connect('localhost',$user,$pass) or die(mysql_error());
if(!is_resource($conn)) {
die("Error connecting to mysql.\n");
}
@mysql_select_db($db,$conn);
$sql = "SELECT * FROM $table WHERE id=$id";
$result = @mysql_query($sql,$conn)or die(mysql_error());
$sql2 = "SELECT * from $table";
$num_res = mysql_query($sql2,$conn);
$num_entries = mysql_num_rows($num_res);
print '<TR>';
print '<TD width=33%><img src=getdata.php?id='.$id.'&table='.$table.' width=404 height=295></TD>';
print '<TD width=33%>'.$description.'</TD>';
print '<TD width=33%>'.$section.'</TD>';
print '</TR>';
while ($newarray = @mysql_fetch_array($result, MYSQL_BOTH)) {
$description = $newarray['description'];
$section = $newarray['section'];
}
}
//echo $description;
//echo $section;
?>
</TABLE>
</BODY>
</HTML>
I have been agonizing over this the past 5 days and cannot seem to get it working in sync. I think it has to do with ID starting with 1 and fields starting with 0 but I dont know how to solve it. I need someone to help....I can email the full code if necessary.
Thank you for your help.
-Steve