Jump to content

Onclick checkbox that inserts data into a Database


law

Recommended Posts

How can i make an onclick checkbox that inserts data into my database?

all i want is for the checkbox upon being clicked to change the value of my picks column in my database between 1 and 0. 1 if the box is checked and 0 if it is not. Here is the query that selects the column i wish to edit. "SELECT paid FROM members WHERE id = "$id""

I literally know nothing about javascript so im looking for the exact code or some good explanation.. because if i have to edit the code myself there is a 50% chance i will screw it up! thanks guys! i appreciate your time

Link to comment
Share on other sites

 

Well first off your using the mysql; you need to be using UPDATE. Then you will have to add an onclick event to a checkbox that will submit your form variable values to you php/mysql.

 

something like:

 

<script language="javascript">
function addinfo()
{
document.msqlfs.submit();
}
</script>

I have been here:<br><br>

<form name="msqlfs" action="myphpandmysqlpage.php" method="post">
<input type="checkbox" name="checkboxnamehere" value="0" onclick="addinfo()"> Never
<input type="checkbox" name="checkboxnamehere" value="1" onclick="addinfo()"> Once
</form>

 

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.