Hi There,
I am having trouble with the second bit of code below. What I want is for my results to be displayed in 2 columns from left to right. The first bit of code works fine, but just displays the result in one column. When using the second bit of code the page and html is all displayed but not the results from the database. Can anyone advise???
Working version but displayed in one column:
<table>
<?php
$conn = mysql_connect("localhost","root","password")
or die(mysql_error());
mysql_select_db("database",$conn) or die(mysql_error());
$sql = "SELECT * from table_name";
$result = mysql_query($sql, $conn) or die(mysql_error());
while ($newArray = mysql_fetch_array($result))
{
$id = $newArray['id'];
$name = $newArray['name'];
$thumb_img = $newArray['thumb_img'];
echo "
<td border=\"1\" bordercolor=\"#003366\" cellspacing=\"5\" bgcolor=\"#ffffff\">
<input type=\"radio\" name=\"designs\" value=\"$id\" onclick=\"function();\">
$name
<image src=\"http://www.way/to/images/folder/$thumb_img\" width=\"130px\" height=\"130px\">
</td>";
}
?>
</table>
Non-working version trying to display in 2 columns:
<table>
<?php
$conn = mysql_connect("localhost","root","password")
or die(mysql_error());
mysql_select_db("database",$conn) or die(mysql_error());
$sql = "SELECT * from table_name";
$result = mysql_query($sql, $conn) or die(mysql_error());
for($i = 0; $i < $numofrows; $i++)
{
if (!$i % 2)
{
echo "<tr>";
}
while ($newArray = mysql_fetch_array($result))
{
$id = $newArray['id'];
$name = $newArray['name'];
$thumb_img = $newArray['thumb_img'];
echo "
<td border=\"1\" bordercolor=\"#003366\" cellspacing=\"5\" bgcolor=\"#ffffff\">
<input type=\"radio\" name=\"designs\" value=\"$id\" onclick=\"function();\">
$name
<image src=\"http://www.way/to/images/folder/$thumb_img\" width=\"130px\" height=\"130px\">
</td>";
}
if ($i % 2)
{
echo "</tr>";
}
}
?>
</table>