JackJack Posted April 7, 2006 Share Posted April 7, 2006 Well this code is really long (only has 2 shops and i need to have about 15). Also for every item there is it posts another Table saying "name type, price".Please Help[code]<? include("../inc/headers.inc.php");$title = "Shops";echo "<a href=shops.php?shop=owl target=mainframe>Eeylops Owl Emporium</a><br>";echo "<a href=shops.php?shop=flourish target=mainframe>Flourish and Blotts</a><br>";if ($shop == "owl") { $owlsel = mysql_query("SELECT * FROM items WHERE slot='owl' and owner=0 order by price asc"); while ($item = mysql_fetch_array($owlsel)){echo "<br><br><table border='0' cellpadding='0' cellspacing='0' width='100%'><th width='34%' align='center' height='25' bgcolor=#cccccc><h4>Name</h4></td> <th width='33%' align='center' height='25' bgcolor=#cccccc><h4>Type</h4></td> <th width='33%' align='center' height='25' bgcolor=#cccccc><h4>Price</h4></td><td align='center' height='25'>$item[name]</td><td align='center' height='25'>$item[type]</td><td align='center' height='25'>$item[price]</td>";}}if ($shop == "flourish") { $flourishsel = mysql_query("SELECT * FROM items WHERE slot='flourish' and owner=0 order by price asc"); while ($item = mysql_fetch_array($flourishsel)){echo "<table border='0' cellpadding='0' cellspacing='0' width='100%'><th width='34%' align='center' height='25' bgcolor=#cccccc><h4>Name</h4></td> <th width='33%' align='center' height='25' bgcolor=#cccccc><h4>Type</h4></td> <th width='33%' align='center' height='25' bgcolor=#cccccc><h4>Price</h4></td><td align='center' height='25'>$item[name]</td><td align='center' height='25'>$item[type]</td><td align='center' height='25'>$item[price]</td>";}}?>[/code] Thank youJJ Quote Link to comment Share on other sites More sharing options...
JackJack Posted April 7, 2006 Author Share Posted April 7, 2006 Bumpety Bump Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 7, 2006 Share Posted April 7, 2006 What is your problem? You posted a large chunk of code with no explanation of why you posted.Ken Quote Link to comment Share on other sites More sharing options...
JackJack Posted April 7, 2006 Author Share Posted April 7, 2006 The problem is If there is more than object in the MySql database then it posts another line with Name Type PriceOn it.Also the code is really long and i need to add about 8x more stuff in so i was wondering if anyone could shorten it a bit please.Thank youJJ Quote Link to comment Share on other sites More sharing options...
Zane Posted April 7, 2006 Share Posted April 7, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Also the code is really long and i need to add about 8x more stuff in so i was wondering if anyone could shorten it a bit please.[/quote]you can't just post code and ask us to fix it up for you....you need to shorten it yourself and then explain what you need help onand FYI your problem is that you're putting the row for NAME PRICE etc inside your while loopstart the table first then put the while loopand end the table after the loop Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 7, 2006 Share Posted April 7, 2006 You can definiatly shorten it by miles:[code]<?php$title = "Shops";echo "<a href=shops.php?shop=owl target=mainframe>Eeylops Owl Emporium</a><br>";echo "<a href=shops.php?shop=flourish target=mainframe>Flourish and Blotts</a><br>";//rest of shop links here!$sql = mysql_query("SELECT * FROM items WHERE slot='$shop' and owner=0 order by price asc");while ($item = mysql_fetch_array($sql)){ echo "<br><br><table border='0' cellpadding='0' cellspacing='0' width='100%'><th width='34%' align='center' height='25' bgcolor=#cccccc><h4>Name</h4></td><th width='33%' align='center' height='25' bgcolor=#cccccc><h4>Type</h4></td><th width='33%' align='center' height='25' bgcolor=#cccccc><h4>Price</h4></td><td align='center' height='25'>$item[name]</td><td align='center' height='25'>$item[type]</td><td align='center' height='25'>$item[price]</td>";}?>[/code] 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.