Jump to content

Need a pushing in right direction


xoligy

Recommended Posts

Ok ive been trying to add multiple submit buttons to a page that basically update something in the db (simple eh!) problem im having is i carn't find the right info i require well i dont think i can anyway i look at the code ty and no luck :confused:

 

Here is the code i was using that works on one submit button its not the best coding i know and thats why i need a push in the right direction:

<?
if($_POST[medals]){
mysql_query("UPDATE $tab[pimp] SET medals='off' WHERE id=$pimp[id]");
} // can use }else{ here i know
if($_POST[medals]){
mysql_query("UPDATE $tab[pimp] SET medals='on' WHERE id=$pimp[id]");
}
$tog = mysql_fetch_array(mysql_query("SELECT medals FROM $tab[pimp]  WHERE id=$pimp[id]"));
if($tog[0] == "on"){$toggle="on";} // can be removed i know
else{$toggle="off";} // can be removed i know
?>
<td><form method="post" action=""><input type="submit" name="<?=$toggle?>" value="<?=$toggle?>"></td>

 

Now if i added a new button and with a new function it looks like it works but then it fails because you click "on" on one and it switches the other off lol

 

Can someone point me in the right direction of a good tutorial or have patience and help me out?

Link to comment
https://forums.phpfreaks.com/topic/168569-need-a-pushing-in-right-direction/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.