I'm new at PHP. What I'm trying to accomplish is creating a form that has many radio buttons, drop down lists and text fields and submitting the data to a MYSQL database without using a submit button on the form.
Here is one of the objects on the page:
<p align="left">Draft Type: <input type="radio"CHECKED value=A onclick="update_db('draft_type',this.value)"
name=draft_type > Annual
<input type=radio value=W onclick="update_db('draft_type',this.value)" name=draft_type > Weekly</p>
I created a function on the page that does nothing but updates the database passing in the value as shown below.
function update_db(field,test12)
{
document.getElementById("answer").value=test12;
<?
$league_id = 101;
$sql_usr_details = "INSERT INTO league_options(league_id,season_start,season_end)
values('$league_id','2009-10-7','2009-12-20')";
mysql_query($sql_usr_details);
?>
if (field=='draft_type')
{
<?
$sql_update = "update league_options set draft_type = '$draft_type' where league_id = '$league_id'";
mysql_query($sql_update)
?>
}
}
The function does execute but I cannot figure out how to get the value being passed to "test12" into the SQL update command and the $draft_type variable.
Thanks in advance
Jerry
Here is one of the objects on the page:
<p align="left">Draft Type: <input type="radio"CHECKED value=A onclick="update_db('draft_type',this.value)"
name=draft_type > Annual
<input type=radio value=W onclick="update_db('draft_type',this.value)" name=draft_type > Weekly</p>
I created a function on the page that does nothing but updates the database passing in the value as shown below.
function update_db(field,test12)
{
document.getElementById("answer").value=test12;
<?
$league_id = 101;
$sql_usr_details = "INSERT INTO league_options(league_id,season_start,season_end)
values('$league_id','2009-10-7','2009-12-20')";
mysql_query($sql_usr_details);
?>
if (field=='draft_type')
{
<?
$sql_update = "update league_options set draft_type = '$draft_type' where league_id = '$league_id'";
mysql_query($sql_update)
?>
}
}
The function does execute but I cannot figure out how to get the value being passed to "test12" into the SQL update command and the $draft_type variable.
Thanks in advance
Jerry