pouncer Posted March 6, 2007 Share Posted March 6, 2007 This is my table code: echo "<table width=90% cellpadding=0 cellspacing=10 border=0 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\"><br>itemid: $item_id<a href=\"manageitem.php?item_id=$item_id\">Manage</a></td>"; if($i % 4 == 0) echo "</tr>"; } echo "</table>"; But from this image: http://img249.imageshack.us/my.php?image=errorqw9.jpg something is not right. the itemid should be like: 7,8,9,10.. etcwhy do my images appear in the wrong order, they appear in: 9,8,7,10 :s Quote Link to comment Share on other sites More sharing options...
komquat Posted March 6, 2007 Share Posted March 6, 2007 What do you want printed out of the images? Also, you can change the order by changing the sql statement to "ORDER BY item_id" Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted March 6, 2007 Share Posted March 6, 2007 use while() not for() <?php while($row = mysql_fetch_array($query)){ $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\"><br>itemid: $item_id<a href=\"manageitem.php?item_id=$item_id\">Manage</a></td>"; if($i % 4 == 0) echo "</tr>"; } ?> Quote Link to comment Share on other sites More sharing options...
pouncer Posted March 6, 2007 Author Share Posted March 6, 2007 What do you want printed out of the images? Also, you can change the order by changing the sql statement to "ORDER BY item_id" perfect, thanks. The images are items, when they click on Manage, it will take the user to that items manage page where they can edit the info for that particular item. boo_lolly, using a while loop ok, but what about the $i ? Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted March 7, 2007 Share Posted March 7, 2007 What do you want printed out of the images? Also, you can change the order by changing the sql statement to "ORDER BY item_id" perfect, thanks. The images are items, when they click on Manage, it will take the user to that items manage page where they can edit the info for that particular item. boo_lolly, using a while loop ok, but what about the $i ? sorry i missed that. <?php $i = 1 while($row = mysql_fetch_array($query)){ $item_id = $row['item_id']; $cat = $row['category']; $_item = new uniqueItem($item_id, $cat); $img = $_item->getImageURL(); (($img != "") ? ($image = "../". $img) : (""); else $image = "../index_images/create_avatar.gif"; (($i % 4 == 0)) ? ("<tr>") : (""));; echo "<td align=center><img src=\"$image\"><br>itemid: $item_id<a href=\"manageitem.php?item_id=$item_id\">Manage</a></td>"; (($i % 4 == 0)) ? ("</tr>") : ("")); $i++; } ?> 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.