Hi,
I just started using check boxes to send information to mySQL. What I want to do is to send id of the user and article to database when check box is clicked and when it is un-clicked remove that information from database.
Right now I am at this stage
So right now I display the check box for logged in user
on every article that is on the page.
What I want to do next is to somehow collect information from that check box, I assume that I will need to place check box inside <form method="post"> , but is it necessarily or can I somehow set method to post in the <input>?
After that I will need to find out if check box is checked or not. So I can than update information. I don't think I understand code behind this part, but I know what I need could be explained like this (I will write //comments in parts that I don't understand) :
I don't know if it matters, but just in case I am using several check boxes on one page.
Thank You
I just started using check boxes to send information to mySQL. What I want to do is to send id of the user and article to database when check box is clicked and when it is un-clicked remove that information from database.
Right now I am at this stage
Code:
<?php
if (isset(//if user is logged in)) {
$addFavorite = '<input type="checkbox" id="favoriteIt" name="favoriteIt" />'; }
else {
$addFavorite = ""; }
$asrticleDisplaylist = '<div>'.$addFavorite.'</div>';
?>
on every article that is on the page.
What I want to do next is to somehow collect information from that check box, I assume that I will need to place check box inside <form method="post"> , but is it necessarily or can I somehow set method to post in the <input>?
After that I will need to find out if check box is checked or not. So I can than update information. I don't think I understand code behind this part, but I know what I need could be explained like this (I will write //comments in parts that I don't understand) :
Code:
if //check box is clicked
$sql = mysql_query("INSERT INTO favorites (article_id, user_id) VALUES ($article_id, $user_id)");
else
if //check box is not checked
//Delete stuff from database
Thank You
Comment