please help. looping

i am making a code for a php game of mine, but i am not sure how to loop?

[code] $chance = rand(1,2);
if ($chance == 1){
$page .= “

You hammer the “.$itemsrow[‘name’].” bars in a beautiful “.$itemsrow2[‘name’].””;
$insertquery = doquery(“INSERT INTO {{table}} SET id=’’,userid=’”.$userrow[“id”]."’,itemnum=’$makeitem’,equipped=‘0’", “inventory”);

for ($counter=0;$$counter<=$amount;$counter+=1){
$invquery = doquery(“SELECT * FROM {{table}} WHERE userid=’$yourid’ AND itemnum=’$itemnum’”, “inventory”);
$invrow = mysql_fetch_array($invquery);
$updatequery = doquery(“DELETE FROM {{table}} WHERE id=’”.$invrow[‘id’]."’", “inventory”);}

}

[/code]

I am trying to delete the number of rows that is listed in $amount.
in this case $amount = 3

but for some reason this makes amount = to infinity. i just took that loop code off another site because i dont know anything about them.

if someone could please help me that would be great.

if you need additional code/information it will be provided

[code] for ($counter=0;$counter<=$amount;$counter+=1){
$invquery = doquery(“SELECT * FROM {{table}} WHERE userid=’$yourid’ AND itemnum=’$itemnum’”, “inventory”);
$invrow = mysql_fetch_array($invquery);
$updatequery = doquery(“DELETE FROM {{table}} WHERE id=’”.$invrow[‘id’]."’", “inventory”);}

}

[/code]

never mind fixed it hehe

also if anyone is stealing my code $counter=0; should be $counter=1;

:slight_smile:

thx

Sponsor our Newsletter | Privacy Policy | Terms of Service