almightyegg Posted June 1, 2008 Share Posted June 1, 2008 I've done 3 whiles that while the same content but pick out different parts but only the first one is working... $select = mysql_query("SELECT * FROM itemsowned WHERE userid = '{$mem['id']}'"); $howmany = mysql_num_rows($select); if($howmany == 0){ echo "You have no items.<br>"; }else{ echo "Alchemy<br>"; while($item = mysql_fetch_array($select)){ $details = mysql_fetch_array(mysql_query("SELECT * FROM items WHERE code = '{$item['code']}'")); $amount = number_format($item[amount]); if($details[section] == 1){ if($details[sell] == No){ echo "$details[name] ($amount)<br>"; }else{ echo "<a href='market/market.php?code=$item[code]&sort=$mem[sortmarket]'>$details[name]</a> ($amount)<br>"; } } } echo "Materials<br>"; while($item = mysql_fetch_array($select)){ $details = mysql_fetch_array(mysql_query("SELECT * FROM items WHERE code = '{$item['code']}'")); $amount = number_format($item[amount]); if($details[section] == 2){ if($details[sell] == No){ echo "$details[name] ($amount)<br>"; }else{ echo "<a href='market/market.php?code=$item[code]&sort=$mem[sortmarket]'>$details[name]</a> ($amount)<br>"; } } } echo "Pit Items<br>"; while($item = mysql_fetch_array($select)){ $details = mysql_fetch_array(mysql_query("SELECT * FROM items WHERE code = '{$item['code']}'")); $amount = number_format($item[amount]); if($details[section] == 3){ if($details[sell] == No){ echo "$details[name] ($amount)<br>"; }else{ echo "<a href='market/market.php?code=$item[code]&sort=$mem[sortmarket]'>$details[name]</a> ($amount)<br>"; } } } } It echos out the right stuff rom first while then the other 2 don't send anything out[/code][/code][/code] Link to comment https://forums.phpfreaks.com/topic/108235-why-arent-these-whiles-working/ Share on other sites More sharing options...
whizard Posted June 1, 2008 Share Posted June 1, 2008 if($details['sell'] == No) You need to put No inside double quotes Link to comment https://forums.phpfreaks.com/topic/108235-why-arent-these-whiles-working/#findComment-554806 Share on other sites More sharing options...
almightyegg Posted June 1, 2008 Author Share Posted June 1, 2008 That bit works in the first one though... Link to comment https://forums.phpfreaks.com/topic/108235-why-arent-these-whiles-working/#findComment-554807 Share on other sites More sharing options...
BlueSkyIS Posted June 1, 2008 Share Posted June 1, 2008 you should have ALL strings quoted. not only 'No' in your if's but also your array indexes, $details['section'], etc. No != 'No' Link to comment https://forums.phpfreaks.com/topic/108235-why-arent-these-whiles-working/#findComment-554862 Share on other sites More sharing options...
almightyegg Posted June 1, 2008 Author Share Posted June 1, 2008 I changed that and it comes up with: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/lordofth/public_html/house.php on line 252 line 252: echo "<a href='market/market.php?code=$item &sort=$mem[sortmarket]'>$details[name]</a> ($amount)<br>"; I tried changing that to this: echo "<a href=\"market/market.php?code=$item['code']&sort=$mem['sortmarket']\">$details['name']</a> ($amount)<br>"; But no joy Link to comment https://forums.phpfreaks.com/topic/108235-why-arent-these-whiles-working/#findComment-554873 Share on other sites More sharing options...
BlueSkyIS Posted June 1, 2008 Share Posted June 1, 2008 echo "<a href='market/market.php?code={$item['code']}&sort={$mem['sortmarket']}'>{$details['name']}</a> ($amount)<br>"; Link to comment https://forums.phpfreaks.com/topic/108235-why-arent-these-whiles-working/#findComment-554885 Share on other sites More sharing options...
almightyegg Posted June 1, 2008 Author Share Posted June 1, 2008 Still shows the error. But I really don't think it's an error with that anyway because the first one works fine... Link to comment https://forums.phpfreaks.com/topic/108235-why-arent-these-whiles-working/#findComment-554905 Share on other sites More sharing options...
almightyegg Posted June 1, 2008 Author Share Posted June 1, 2008 I don't know what I changed but the error has now gone. Still showing wrong info... $select = mysql_query("SELECT * FROM itemsowned WHERE userid = '{$mem['id']}'"); $howmany = mysql_num_rows($select); if($howmany == 0){ echo "You have no items.<br>"; }else{ echo "Alchemy<br>"; while($item = mysql_fetch_array($select)){ $details = mysql_fetch_array(mysql_query("SELECT * FROM items WHERE code = '{$item['code']}'")); $amount = number_format($item[amount]); if($details['section'] == '1'){ if($details['sell'] == 'No'){ echo " $details[name] ($amount)<br>"; }else{ echo " <a href='market/market.php?code={$item['code']}&sort={$mem['sortmarket']}'>{$details['name']}</a> ($amount)<br>"; } } } echo "Materials<br>"; while($item = mysql_fetch_array($select)){ $details = mysql_fetch_array(mysql_query("SELECT * FROM items WHERE code = '{$item['code']}'")); $amount = number_format($item[amount]); if($details['section'] == '2'){ if($details['sell'] == 'No'){ echo " $details[name] ($amount)<br>"; }else{ echo " <a href='market/market.php?code={$item['code']}&sort={$mem['sortmarket']}'>{$details['name']}</a> ($amount)<br>"; } } } echo "Pit Items<br>"; while($item = mysql_fetch_array($select)){ $details = mysql_fetch_array(mysql_query("SELECT * FROM items WHERE code = '{$item['code']}'")); $amount = number_format($item[amount]); if($details['section'] == '3'){ if($details['sell'] == 'No'){ echo " $details[name] ($amount)<br>"; }else{ echo " <a href='market/market.php?code={$item['code']}&sort={$mem['sortmarket']}'>{$details['name']}</a> ($amount)<br>"; } } } } This echos: Inventory Alchemy Blah (1) Blah (87) Blah(1,000) Blah (10) Blah (119) Blah (2) Materials Pit Items And there are definitely things that sould show up in materials and pit items.... Link to comment https://forums.phpfreaks.com/topic/108235-why-arent-these-whiles-working/#findComment-554912 Share on other sites More sharing options...
AndyB Posted June 1, 2008 Share Posted June 1, 2008 you should have ALL strings quoted. not only 'No' in your if's but also your array indexes, $details['section'], etc. No != 'No' I changed that .... Not if what you just posted is your current code. Link to comment https://forums.phpfreaks.com/topic/108235-why-arent-these-whiles-working/#findComment-554927 Share on other sites More sharing options...
almightyegg Posted June 1, 2008 Author Share Posted June 1, 2008 What have I missed then? Link to comment https://forums.phpfreaks.com/topic/108235-why-arent-these-whiles-working/#findComment-554937 Share on other sites More sharing options...
almightyegg Posted June 2, 2008 Author Share Posted June 2, 2008 I might have miss understood what BlueSkyIS said then... you should have ALL strings quoted. not only 'No' in your if's but also your array indexes, $details['section'], etc. No != 'No' I changed that .... Not if what you just posted is your current code. What havn't I done? Or what have I done wrong? Link to comment https://forums.phpfreaks.com/topic/108235-why-arent-these-whiles-working/#findComment-555728 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.