DBookatay Posted March 20, 2006 Share Posted March 20, 2006 I'm sure this one is easy for someone with more experience to figure out, but after spending over 2 hours of looking at errors I'm stumped...I'm trying to create a page where you view items, and have 3 rows, with 3 items per row, a total of 9 images per page. I was able to get the 3 rows to work, but can't seem to get the 3 items per row to take shape. Can somebody look at my code and tell me what I have to do?[code]<?phpif(isset($_GET['category'])); switch($_GET['category']) { case 'bracelets': $pTitle = 'Bracelets'; break; case 'cufflinks': $pTitle = 'Cufflinks'; break; case 'nameplates': $pTitle = 'Nameplates'; break; case 'pendants': $pTitle = 'Pendants'; break; case 'Earrings': $pTitle = 'Our Earring Collection'; break; case 'moneyclips': $pTitle = 'Money Clips'; break; } include ('include/header.php');?><table> <tr> <td class="shadowL"><img src="images/spacer.gif" width="19" height="1" /></td> <td> <table> <tr> <td class="lftNavHldr"><?php include ('include/leftNav.php'); ?></td> <td class="mainHldr"> <table> <tr><td class="pTitle"><? echo $pTitle; ?></td></tr> </table> <?php require_once ('include/mysql_connect.php'); if(!$_GET['page']) { $_GET['page'] =1; } $offset = ($_GET['page']-1)*3; $query = "SELECT count(*) as thecount from products where category = '{$_GET['category']}' and status = 'Active'"; $result = mysql_query($query); $row = mysql_fetch_array($result); $total = $row[thecount]; $pages = ceil($total/3); $query = "SELECT * FROM products where category = '{$_GET['category']}' and status = 'Active' limit $offset,3"; $result = mysql_query($query); $numrows = mysql_num_rows($result); while($row = mysql_fetch_array($result)){ $image = "<img src=\"products/{$row[Category]}/{$row['SKU']}s.jpg\" width=\"155\" height=\"155\" alt=\"$alt\"/>"; echo " <div align=\"center\"> <table> <tr> <td class=\"itmHldr\"> <table width=\"100%\"> <tr><td class=\"imgHldrS\"><a href=\"view_item.php?SKU={$row['SKU']}\">$image</a></td></tr> <tr><td class=\"itmDescS\">{$row['Desc_S']}</td></tr> </table> <div align=\"center\"> <table> <tr> <td class=\"prc1S\">M.S.R.P</td> <td class=\"prc2S\">$ {$row['MSRP']}</td> </tr> <tr> <td class=\"prc3S\">Your Price</td> <td class=\"prc4S\">$ {$row['Sell']}</td> </tr> <tr> <td class=\"prc5S\">You Save</td> <td class=\"prc6S\">$1245.00</td> </tr> </table> </div> </td> <td><img src=\"images/spacer.gif\" width=\"20\" height=\"1\" /></td> <td class=\"itmHldr\"> <table width=\"100%\"> <tr><td class=\"imgHldrS\"><a href=\"view_item.php?SKU={$row['SKU']}\">$image</a></td></tr> <tr><td class=\"itmDescS\">{$row['Desc_S']}</td></tr> </table> <div align=\"center\"> <table> <tr> <td class=\"prc1S\">M.S.R.P</td> <td class=\"prc2S\">$ {$row['MSRP']}</td> </tr> <tr> <td class=\"prc3S\">Your Price</td> <td class=\"prc4S\">$ {$row['Sell']}</td> </tr> <tr> <td class=\"prc5S\">You Save</td> <td class=\"prc6S\">$1245.00</td> </tr> </table> </div> </td> <td><img src=\"images/spacer.gif\" width=\"20\" height=\"1\" /></td> <td class=\"itmHldr\"> <table width=\"100%\"> <tr><td class=\"imgHldrS\"><a href=\"view_item.php?SKU={$row['SKU']}\">$image</a></td></tr> <tr><td class=\"itmDescS\">{$row['Desc_S']}</td></tr> </table> <div align=\"center\"> <table> <tr> <td class=\"prc1S\">M.S.R.P</td> <td class=\"prc2S\">$ {$row['MSRP']}</td> </tr> <tr> <td class=\"prc3S\">Your Price</td> <td class=\"prc4S\">$ {$row['Sell']}</td> </tr> <tr> <td class=\"prc5S\">You Save</td> <td class=\"prc6S\">$1245.00</td> </tr> </table> </div> </td> </tr> </table><br />\n"; $row_count++; } // End of record loop. mysql_close($dbc); ?> </div> <table width="100%"> <tr> <td class="pgNums"> <?for($x = 1; $x<= $pages; $x++) {if($_GET['page'] != $x) { echo "<a href=\"view_items.php?category={$_GET[category]}&page={$x}\">{$x}</a>";}else { echo "[{$x}] ";}} ?> </td> </tr> </table> </td> </tr> </table> </td> <td class="shadowR"><img src="images/spacer.gif" width="19" height="1" /></td> </tr></table><?php include ('include/footer.php'); ?>[/code] Quote Link to comment Share on other sites More sharing options...
ober Posted March 20, 2006 Share Posted March 20, 2006 To use your current method, you would have to call $row = mysql_fetch_array($result) between every < td >. To do it correctly, you need to have a column count, and your containing row would be closed when your column count == 3. That way, you call your main chunk of code that holds the item only once within the loop.I don't know if that makes sense, but it's hard for me to tell what it's currently doing. Quote Link to comment Share on other sites More sharing options...
DBookatay Posted March 21, 2006 Author Share Posted March 21, 2006 [!--quoteo(post=356686:date=Mar 20 2006, 12:59 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Mar 20 2006, 12:59 PM) [snapback]356686[/snapback][/div][div class=\'quotemain\'][!--quotec--]I don't know if that makes sense, but it's hard for me to tell what it's currently doing.[/quote]You're right, that makes NO sense to me... Could you possible show me a working example?I would apprechiate 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.