Hello,
I'm trying to pass the $ball_id value into my submit.php which will insert that value along with every other value into the DB. It inserts a value but the value is alway the number "2", it should reflect the "ball_id" field from the "ball" table which will vary depending on the selection from the drop down list.
Below is the code for generating the select box:
<?
include ("include/header.inc.php");
include("include/dbconnect.php");
// create SQL statement
$sql = "SELECT * FROM ball WHERE active = 'yes'";
// execute SQL query and get result
$sql_result = mysql_query($sql)
or die("Couldn't execute query.");
// put data into drop-down list box
while ($row = mysql_fetch_array($sql_result)) {
$ball_id = $row["ball_id"];
$ball_name = $row["ball_name"];
$option_block .= "<OPTION value=\"$ball_name\">$ball_name</OPTION>";
}
?>
......this is how i display the select box:
<SELECT name="ball">
<option value="" selected> - - - - - Choose a ball - - - - - </option>
<? echo "$option_block"; ?> </SELECT>
...and finally my submit.php page:
<?
include("include/dbconnect.php");
if($submit){
$sql = "insert into orders(orders_id, ball_id, ball, ball_date, order_type, tickets_male, tickets_female, total_amount, order_first_name, order_surname, order_address, order_suburb, order_state, order_post_code, order_email, order_phone, cc_number, cc_type, cc_expiry_month, cc_expiry_year, cc_name, status, trans_number, trans_date, trans_amount, trans_memo)
values(NULL,'$ball_id','$ball','$ball_date','$order_type','$tickets_male','$tickets_female','$total_amount','$order_first_name','$order_surname','$order_address','$order_suburb','$order_state','$order_post_code','$order_email','$order_phone','$cc_number','$cc_type','$cc_expiry_month','$cc_expiry_year','$cc_name','$status','$trans_number','$trans_date','$trans_amount','$trans_memo')";
}
$result = mysql_query($sql);
if($result){
echo "<br>Information uploaded successfully.\n";
}
else {
echo "<br><font color=\"red\"><b>ERROR:</b> Your data could not be updated</font>\n";
}
?>
Any ideas how to select the correct ball_id from the ball table?
Cheers,
micmac