PHP mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
musbah
Forum Newbie
Posts: 11
Joined: Mon Apr 25, 2011 8:52 pm

PHP mysql

Post by musbah »

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:

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 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...
prensil
Forum Newbie
Posts: 15
Joined: Tue Apr 26, 2011 8:38 am
Location: Ahmedabad
Contact:

Re: PHP mysql

Post by prensil »

Can you please elaborate the problem or attach some image example so that we would be having better idea?
musbah
Forum Newbie
Posts: 11
Joined: Mon Apr 25, 2011 8:52 pm

Re: PHP mysql

Post by musbah »

Imagine something like this:

http://img593.imageshack.us/i/13923157.png/

the + and the - ... if i use the code i did now it would change both the episode for the first and second anime i don't know how i could define each name and i probably can't do it using the methode i am using...
Post Reply