Searching for another way to...
Posted: Mon Apr 25, 2011 8:54 pm
I can't explain what i'm having a problem with easily but here it is,
i made it look for rows and their names but a button can't see the difference between 2 arrays in a while function because you click it at the end i need a work arround to be able to see which array the button needs to change the number for, here is the code:
i can't explain it well i hope you can understand what i mean when you read the code, the name that changes is for both names because name='$rows[name]' is just all of the rows...
what kind of function or thing can be a workaround for this??
i made it look for rows and their names but a button can't see the difference between 2 arrays in a while function because you click it at the end i need a work arround to be able to see which array the button needs to change the number for, here is the code:
Code: Select all
$sql="SELECT * FROM anime WHERE username = '$username' ";
$result=mysql_query($sql) or die(mysql_error());
while($rows=mysql_fetch_array($result))
{
if (isset($_POST['submit1']))
{ mysql_query("UPDATE anime SET episode='$rows[episode]'+1 where name='$rows[name]' AND username='$username'") or die("cannot send your password");
header("Location: {$_SERVER['HTTP_REFERER']}");
}
if (isset($_POST['submit2']))
{ mysql_query("UPDATE anime SET episode='$rows[episode]'-1 where name='$rows[name]' AND username='$username'") or die("cannot send your password");
header("Location: {$_SERVER['HTTP_REFERER']}");
}
?>
<form name="myform" action="atview.php" method="post">
<table>
<tr>
<center><td>anime:</td></center>
<center><td><?php echo "$rows[name]"; ?></td></center>
</tr>
<tr>
<center><td>episode:</td></center>
<center><td><input name="submit2" type="submit" value="-" /><?php echo "$rows[episode]"; ?><input name="submit1" type="submit" value="+" /> </td></center>
</tr>
</table>
</form>
<?php
}
mysql_close();what kind of function or thing can be a workaround for this??