[SOLVED] Trouble displaying variable during FOR loop
Posted: Thu Feb 03, 2005 3:42 pm
Code: Select all
<?php include('common.php');
$query = "SELECT * FROM store_items";
$result = mysql_query($query) or die(mysql_error());
$output = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.smallfont {
font-family: "Bavaria Regular";
font-size: 8px;
color: #333333;
}
-->
</style>
</head>
<body bgcolor="f2f1dc" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="smallfont">Test</td>
</tr>
</table>
<table width="500" border="0" cellspacing="0" cellpadding="0">';
$howmany = mysql_num_rows($result);
$rowmax = 3;
for($x = 0; $row = mysql_fetch_array($result); $x++)
{
if($x % $rowmax == 0)
$output .= "<tr>\n";
$item_title = $rowї"item_title"];
$output .= '<td align="center"><table width="135" height="143" border="0" cellpadding="0" cellspacing="0">
<tr valign="top">
<td height="18" colspan="2"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="/test/images/top.jpg">
<tr>
<td width="12"> </td>
<td valign="top" class="smallfont">$item_title</td>
</tr>
</table></td>
</tr>
<tr>
<td width="10"><img src="/test/images/side.jpg" width="10" height="125"></td>
<td><img src="/test/images/image.jpg" width="125" height="125"></td>
</tr>
</table></td>';
if($x % $rowmax == $rowmax - 1)
$output .= "\r</tr>\n\n";
}
$output .= '</table>
</body>
</html>';
echo $output;
?>Thanks for the help!