PHP mysql
Posted: Tue Apr 26, 2011 8:47 pm
Ok well i'm trying to do something but i don't know the proper way i would go about it, i tried doing it but it doesn't work the way i want it.
I want to be able to display data from mysql for example an anime name and episode and be able to click on a button to add to an episode and one to remove from episode till now i was able to do it. Tricky thing is for multiple anime on the same page i need a different way to do it than this:
I can't define the name of the anime to add a + to the episode to because I'm using mysql_fetch_array so i need an alternative way to show the data that can actually define the name of the anime i need to add an episode number to
I hope you can understand what i said because I find it hard to explain, thank you for your help...
I want to be able to display data from mysql for example an anime name and episode and be able to click on a button to add to an episode and one to remove from episode till now i was able to do it. Tricky thing is for multiple anime on the same page i need a different way to do it than this:
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();I hope you can understand what i said because I find it hard to explain, thank you for your help...