pouncer Posted April 5, 2007 Share Posted April 5, 2007 this is supposed to output a table, with 3 items per row.. but it messes up for some reason. heres my code echo "<table width=90% cellpadding=0 cellspacing=10 border=1 align=center>"; echo "<tr>"; echo "<th></th>"; echo "<th></th>"; echo "<th></th>"; echo "</tr>"; for ($i = 1; $row = mysql_fetch_array($qry, MYSQL_ASSOC); $i++) { $item_id = $row['item_id']; $cat = $row['category']; $_item = new uniqueItem($item_id, $cat); $img = $_item->getImageURL(); if ($img != "") $image = "../" . $img; else $image = "../index_images/create_avatar.gif"; if ($i % 4 == 0) echo "<tr>"; echo "<td align=center> <img src=\"$image\"> $i <br> <a href=\"manageitem.php?item_id=$item_id\">Manage</a> <br> <a href=\"delete_item.php?item_id=$item_id\">Delete</a> </td>"; if($i % 4 == 0) echo "</tr>"; } echo "</table>"; but my problem is, say i have 7 items , it displays like this on the page <item1> <item 2> <item 3> <item 4> <item5> <item 6> <item 7> it shud be like this.. <item1> <item 2> <item 3> <item 4> <item 5> <item 6> <item7> whats the problem guys? Quote Link to comment Share on other sites More sharing options...
only one Posted April 5, 2007 Share Posted April 5, 2007 echo "<th></th>"; echo "<th></th>"; echo "<th></th>"; stf is a th? its td.... echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; Quote Link to comment Share on other sites More sharing options...
pouncer Posted April 5, 2007 Author Share Posted April 5, 2007 no they are just blank headers Quote Link to comment Share on other sites More sharing options...
Barand Posted April 5, 2007 Share Posted April 5, 2007 Use code tags. Thats all over the place when I copy and paste the code into my editor. By the time I've sorted out the formatting I've lost interest in the original problem. Quote Link to comment Share on other sites More sharing options...
only one Posted April 5, 2007 Share Posted April 5, 2007 <tr><td> </td></tr> you cant open a table row without a column Quote Link to comment Share on other sites More sharing options...
pouncer Posted April 5, 2007 Author Share Posted April 5, 2007 thats inside the loop! if ($i % 4 == 0) echo "<tr>"; echo "<td align=center> <img src=\"$image\"> $i <br> <a href=\"manageitem.php?item_id=$item_id\">Manage</a> <br> <a href=\"delete_item.php?item_id=$item_id\">Delete</a> </td>"; if($i % 4 == 0) echo "</tr>"; i want it to display by a 3 x 3 table.. all items going down the page Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted April 5, 2007 Share Posted April 5, 2007 echo "<th></th>"; echo "<th></th>"; echo "<th></th>"; stf is a th? its td.... echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; google it. @ pouncer: what does the html source look like? Quote Link to comment Share on other sites More sharing options...
only one Posted April 5, 2007 Share Posted April 5, 2007 <table width="200" border="1"> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> </tr> </table> already have googled it... Quote Link to comment Share on other sites More sharing options...
pouncer Posted April 5, 2007 Author Share Posted April 5, 2007 <table width=90% cellpadding=0 cellspacing=10 border=0 align=center><tr><th></th><th></th><th></th></tr><td align=center> <img src="../thumbnail.php?im=collection_items/John_images/godfather1.jpg"> <br> <a href="manageitem.php?item_id=7">Manage</a> <br> <a href="delete_item.php?item_id=7">Delete</a> </td><td align=center> <img src="../thumbnail.php?im=collection_items/John_images/carlitos-way.jpg"> <br> <a href="manageitem.php?item_id=8">Manage</a> <br> <a href="delete_item.php?item_id=8">Delete</a> </td><td align=center> <img src="../thumbnail.php?im=collection_items/John_images/godfather1.jpg"> <br> <a href="manageitem.php?item_id=9">Manage</a> <br> <a href="delete_item.php?item_id=9">Delete</a> </td><tr><td align=center> <img src="../index_images/create_avatar.gif"> <br> <a href="manageitem.php?item_id=12">Manage</a> <br> <a href="delete_item.php?item_id=12">Delete</a> </td></tr><td align=center> <img src="../index_images/create_avatar.gif"> <br> <a href="manageitem.php?item_id=19">Manage</a> <br> <a href="delete_item.php?item_id=19">Delete</a> </td></table> </span></span><br> <span class="style15"> </span><br> Quote Link to comment Share on other sites More sharing options...
Barand Posted April 5, 2007 Share Posted April 5, 2007 try <?php echo "<table width=90% cellpadding=0 cellspacing=10 border=1 align=center>"; echo "<tr>"; echo "<th></th>"; echo "<th></th>"; echo "<th></th>"; echo "</tr>"; $i = 0; while ($row = mysql_fetch_array($qry, MYSQL_ASSOC)) { $item_id = $row['item_id']; $cat = $row['category']; $_item = new uniqueItem($item_id, $cat); $img = $_item->getImageURL(); if ($img != "") $image = "../" . $img; else $image = "../index_images/create_avatar.gif"; if ($i % 3 == 0) echo "<tr>"; echo "<td align=center> <img src=\"$image\"> $i <br> <a href=\"manageitem.php?item_id=$item_id\">Manage</a> <br> <a href=\"delete_item.php?item_id=$item_id\">Delete</a> </td>"; $i++; if ($i % 3 == 0) echo "</tr>"; } echo "</table>"; ?> Quote Link to comment Share on other sites More sharing options...
pouncer Posted April 5, 2007 Author Share Posted April 5, 2007 Barand, absolutely awesome - that fixed it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.