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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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