Jump to content

Why aren't these whiles working?


almightyegg

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.