Posted by J.O. Aho on 11/23/06 10:00
Gaga wrote:
> Hi to all !
>
> How to insert one value of the radio button int db. ?
> <input type="radio" name="option" value="male">
> <input type="radio" name="option" value="female">
>
> ----------------------------------------------------------
> How to make the same but with checkbox ?
> <input type="checkbox" name="checkbox" value="male">
> <input type="checkbox" name="checkbox" value="female">
>
> ---------------------------------------------------------
> How to insert selected value from the dropdown menu ?
> <select name="year" id="year">
> <option>2005</option>
> <option>2006</option>
> </select>
>
> ---------------------------------------------------------------------
>
>
/* assume you have already connected to database and you use mysql */
/* change the "option" in the $_REQUEST[] to the name you used in the form */
$query="INSERT INTO table(column_name) VALUES('".$_REQUEST['option']."')";
/* if you use another database, change the mysql part to the one for your
database or odbc if your database isn't supported by php */
mysql_query($query);
As checkboxes may generate more than one value, the $_REQUEST['checkbox'] may
be a array in which you have to make a for loop.
//Aho
[Back to original message]
|