Enjoy an ad free experience by logging in. Not a member yet?
Register .
10-14-2012, 07:33 AM
PM User |
#1
New Coder
Join Date: Jul 2012
Location: Philippines
Posts: 35
Thanks: 5
Thanked 0 Times in 0 Posts
Select(list/menu) help
i want to be able to add data into my database from a dropdown list i created in dreamweaver. i cannot seem to find any solution i am a newbie in mysql.
for example:
table_delivery has 4 columns delivery_origin, delivery_destination,delivery_payment & delivery_service.
and these 4 columns must get data from the dropdown menu i created
how to do this in dreamweaver?
10-14-2012, 04:31 PM
PM User |
#2
Senior Coder
Join Date: Jan 2011
Location: Missouri
Posts: 2,383
Thanks: 18
Thanked 350 Times in 349 Posts
Post the <form> that contains the four drop downs.
10-14-2012, 06:04 PM
PM User |
#3
New Coder
Join Date: Jul 2012
Location: Philippines
Posts: 35
Thanks: 5
Thanked 0 Times in 0 Posts
Code:
<form id="formsub" name="formsub" method="POST">
<table width="626" border="1" cellpadding="5" cellspacing="1">
<tr>
<td width="153">Shipper's Name</td>
<td width="444"><input type="text" name="shipper_name" id="shipper_name" /></td>
</tr>
<tr>
<td>Shipper's Address</td>
<td><input type="text" name="shipper_address" id="shipper_address" /></td>
</tr>
<tr>
<td>Shipper's Email Address</td>
<td><input type="text" name="shipper_email" id="shipper_email" /></td>
</tr>
<tr>
<td>Shipper's Contact Number</td>
<td><input type="text" name="shipper_contactnum" id="shipper_contactnum" /></td>
</tr>
<tr>
<td>Consignee's Name</td>
<td><input type="text" name="consignee_name" id="consignee_name" /></td>
</tr>
<tr>
<td>Consignee's Address</td>
<td><input type="text" name="consignee_address" id="consignee_address" /></td>
</tr>
<tr>
<td>Consignee's Contact Number</td>
<td><input type="text" name="consignee_contactnum" id="consignee_contactnum" /></td>
</tr>
<tr>
<td>Port of Origin</td>
<td><select name="delivery_origin_port" id="delivery_origin_port">
<option value="Manila">Manila</option>
<option value="Aklan">Aklan</option>
<option value="Bacolod">Bacolod</option>
<option value="Batangas">Batangas</option>
<option value="Butuan">Butuan</option>
<option value="Cagayan">Cagayan</option>
<option value="Cebu">Cebu</option>
<option value="Cotabato">Cotabato</option>
<option value="Davao">Davao</option>
<option value="Dipolog">Dipolog</option>
<option value="Dumaguete">Dumaguete</option>
<option value="General Santos">General Santos</option>
<option value="Iligan">Iligan</option>
<option value="Iloilo">Iloilo</option>
<option value="Ozamis">Ozamis</option>
<option value="Puerto Princesa">Puerto Princesa</option>
<option value="Roxas">Roxas</option>
<option value="Surigao">Surigao</option>
<option value="Tacloban">Tacloban</option>
<option value="Tagbilaran">Tagbilaran</option>
<option value="Toledo">Toledo</option>
<option value="Zamboanga">Zamboanga</option>
</select></td>
</tr>
<tr>
<td>Port of Destination</td>
<td><select name="delivery_destination_port" id="delivery_destination_port">
<option value="Manila">Manila</option>
<option value="Aklan">Aklan</option>
<option value="Bacolod">Bacolod</option>
<option value="Batangas">Batangas</option>
<option value="Butuan">Butuan</option>
<option value="Cagayan">Cagayan</option>
<option value="Cebu">Cebu</option>
<option value="Cotabato">Cotabato</option>
<option value="Davao">Davao</option>
<option value="Dipolog">Dipolog</option>
<option value="Dumaguete">Dumaguete</option>
<option value="General Santos">General Santos</option>
<option value="Iligan">Iligan</option>
<option value="Iloilo">Iloilo</option>
<option value="Ozamis">Ozamis</option>
<option value="Puerto Princesa">Puerto Princesa</option>
<option value="Roxas">Roxas</option>
<option value="Surigao">Surigao</option>
<option value="Tacloban">Tacloban</option>
<option value="Tagbilaran">Tagbilaran</option>
<option value="Toledo">Toledo</option>
<option value="Zamboanga">Zamboanga</option>
</select></td>
</tr>
<tr>
<td>Mode of Service</td>
<td><select name="delivery_service" id="delivery_service">
<option value="Pier-to-Pier">Pier-to-Pier</option>
<option value="Pier-to-Door">Pier-to-Door</option>
<option value="Door-to-Pier">Door-to-Pier</option>
<option value="Van Out">Van Out</option>
</select></td>
</tr>
<tr>
<td>Payment Arrangement</td>
<td><select name="delivery_payment" id="delivery_payment">
<option value="Cash">Cash</option>
<option value="With credit line">With credit line</option>
</select></td>
</tr>
<tr>
<td>No. of Containers Required</td>
<td><select name="container_nos." id="container_nos.">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
</select></td>
</tr>
<tr>
<td>Container Size</td>
<td><select name="container_size" id="container_size">
<option value="40 Footer">40 Footer</option>
<option value="20 Footer">20 Footer</option>
<option value="10 Footer">10 Footer</option>
</select></td>
</tr>
<tr>
<td>Container Type</td>
<td><select name="container_type" id="container_type">
<option value="Dry Van">Dry Van</option>
<option value="Reefer Van">Reefer Van</option>
<option value="Fruit Van">Fruit Van</option>
<option value="Cattle Van">Cattle Van</option>
</select></td>
</tr>
<tr>
<td>Complete Pick-Up Address</td>
<td><input type="text" name="delivery_pick_up_address" id="delivery_pick_up_address" /></td>
</tr>
<tr>
<td>Contact Person</td>
<td><input type="text" name="delivey_contact_person" id="delivey_contact_person" /></td>
</tr>
<tr>
<td>Contact No. at Place of Pick-Up</td>
<td><input type="text" name="delivery_pick_up_contactnum" id="delivery_pick_up_contactnum" /></td>
</tr>
</table>
<p>
<input name="Reserve" type="submit" id="Reserve" tabindex="160" value="Reserve Now" />
</p>
</form>
this is my form where do i put the post for my drop down? every other input for my database worsk except for the drop down list it doesnt seem to be able to insert into my database
Last edited by juslai; 10-14-2012 at 06:10 PM ..
10-14-2012, 08:15 PM
PM User |
#4
Super Moderator
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
okay so now where is your code to connect to the database? where is your code to process the form?
10-15-2012, 04:33 AM
PM User |
#5
Senior Coder
Join Date: Jan 2011
Location: Missouri
Posts: 2,383
Thanks: 18
Thanked 350 Times in 349 Posts
Looking at your form everything looks good. Only problem I see is what guelphdad said:
Quote:
where is your code to process the form?
It is the value of the action attribute in the form tag, like this:
Code:
<form id="formsub" name="formsub" method="POST" action="PUT PHP FILE NAME HERE">
And that file must get the POST statements and place them into variables and then add them to the database. example of getting info from first drop down
PHP Code:
<?php $dop = $_POST [ "delivery_origin_port" ]; echo $dop ; ?>
Hope this helps.
10-15-2012, 02:53 PM
PM User |
#6
New Coder
Join Date: Jul 2012
Location: Philippines
Posts: 35
Thanks: 5
Thanked 0 Times in 0 Posts
Code:
<?php require_once('Connections/mysqlconnect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "formsub")) {
$insertSQL = sprintf("INSERT INTO tbl_shipper (shipper_name, shipper_address, shipper_email, shipper_contactnum) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['shipper_name'], "text"),
GetSQLValueString($_POST['shipper_address'], "text"),
GetSQLValueString($_POST['shipper_email'], "text"),
GetSQLValueString($_POST['shipper_contactnum'], "int"));
mysql_select_db($database_mysqlconnect, $mysqlconnect);
$Result1 = mysql_query($insertSQL, $mysqlconnect) or die(mysql_error());
$insertGoTo = "home.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "formsub")) {
$insertSQL = sprintf("INSERT INTO tbl_consignee (consignee_name, consignee_address, consignee_contactnum) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['consignee_name'], "text"),
GetSQLValueString($_POST['consignee_address'], "text"),
GetSQLValueString($_POST['consignee_contactnum'], "int"));
mysql_select_db($database_mysqlconnect, $mysqlconnect);
$Result1 = mysql_query($insertSQL, $mysqlconnect) or die(mysql_error());
$insertGoTo = "home.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "formsub")) {
$insertSQL = sprintf("INSERT INTO tbl_reserve (delivery_origin_port, delivery_destination_port, delivery_service, delivery_payment, delivery_pick_up_address, delivey_contact_person, delivery_pick_up_contactnum) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['delivery_origin_port'], "text"),
GetSQLValueString($_POST['delivery_destination_port'], "text"),
GetSQLValueString($_POST['delivery_service'], "text"),
GetSQLValueString($_POST['delivery_payment'], "text"),
GetSQLValueString($_POST['delivery_pick_up_address'], "text"),
GetSQLValueString($_POST['delivey_contact_person'], "text"),
GetSQLValueString($_POST['delivery_pick_up_contactnum'], "int"));
mysql_select_db($database_mysqlconnect, $mysqlconnect);
$Result1 = mysql_query($insertSQL, $mysqlconnect) or die(mysql_error());
$insertGoTo = "home.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "formsub")) {
$insertSQL = sprintf("INSERT INTO tbl_container_info (container_nos., container_size, container_type) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['container_nos.'], "int"),
GetSQLValueString($_POST['container_size'], "text"),
GetSQLValueString($_POST['container_type'], "text"));
mysql_select_db($database_mysqlconnect, $mysqlconnect);
$Result1 = mysql_query($insertSQL, $mysqlconnect) or die(mysql_error());
$insertGoTo = "home.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_mysqlconnect, $mysqlconnect);
$query_shipper = "SELECT * FROM tbl_shipper";
$shipper = mysql_query($query_shipper, $mysqlconnect) or die(mysql_error());
$row_shipper = mysql_fetch_assoc($shipper);
$totalRows_shipper = mysql_num_rows($shipper);
mysql_select_db($database_mysqlconnect, $mysqlconnect);
$query_consignee = "SELECT * FROM tbl_consignee";
$consignee = mysql_query($query_consignee, $mysqlconnect) or die(mysql_error());
$row_consignee = mysql_fetch_assoc($consignee);
$totalRows_consignee = mysql_num_rows($consignee);
mysql_select_db($database_mysqlconnect, $mysqlconnect);
$query_reserve = "SELECT * FROM tbl_reserve";
$reserve = mysql_query($query_reserve, $mysqlconnect) or die(mysql_error());
$row_reserve = mysql_fetch_assoc($reserve);
$totalRows_reserve = mysql_num_rows($reserve);
mysql_select_db($database_mysqlconnect, $mysqlconnect);
$query_continfo = "SELECT * FROM tbl_container_info";
$continfo = mysql_query($query_continfo, $mysqlconnect) or die(mysql_error());
$row_continfo = mysql_fetch_assoc($continfo);
$totalRows_continfo = mysql_num_rows($continfo);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Reservation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
#apDiv1 {
position:absolute;
left:392px;
top:139px;
width:841px;
height:1000px;
z-index:1;
}
</style>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div id="apDiv1">
<form action="<?php echo $editFormAction; ?>" id="formsub" name="formsub" method="POST">
<table width="626" border="1" cellpadding="5" cellspacing="1">
<tr>
<td width="153">Shipper's Name</td>
<td width="444"><input type="text" name="shipper_name" id="shipper_name" /></td>
</tr>
<tr>
<td>Shipper's Address</td>
<td><input type="text" name="shipper_address" id="shipper_address" /></td>
</tr>
<tr>
<td>Shipper's Email Address</td>
<td><input type="text" name="shipper_email" id="shipper_email" /></td>
</tr>
<tr>
<td>Shipper's Contact Number</td>
<td><input type="text" name="shipper_contactnum" id="shipper_contactnum" /></td>
</tr>
<tr>
<td>Consignee's Name</td>
<td><input type="text" name="consignee_name" id="consignee_name" /></td>
</tr>
<tr>
<td>Consignee's Address</td>
<td><input type="text" name="consignee_address" id="consignee_address" /></td>
</tr>
<tr>
<td>Consignee's Contact Number</td>
<td><input type="text" name="consignee_contactnum" id="consignee_contactnum" /></td>
</tr>
<tr>
<td>Port of Origin</td>
<td><select name="delivery_origin_port" id="delivery_origin_port">
<option value="Manila"><? if($delivery_origin_port=='Manila') echo ' selected="selected"'; ?>Manila</option>
<option value="Aklan"><? if($delivery_origin_port=='Aklan') echo ' selected="selected"'; ?>Aklan</option>
<option value="Bacolod"><? if($delivery_origin_port=='Bacolod') echo ' selected="selected"'; ?>Bacolod</option>
<option value="Batangas"><? if($delivery_origin_port=='Batangas') echo ' selected="selected"'; ?>Batangas</option>
<option value="Butuan"><? if($delivery_origin_port=='Butuan') echo ' selected="selected"'; ?>Butuan</option>
<option value="Cagayan"><? if($delivery_origin_port=='Cagayan') echo ' selected="selected"'; ?>Cagayan</option>
<option value="Cebu"><? if($delivery_origin_port=='Cebu') echo ' selected="selected"'; ?>Cebu</option>
<option value="Cotabato"><? if($delivery_origin_port=='Cotabato') echo ' selected="selected"'; ?>Cotabato</option>
<option value="Davao"><? if($delivery_origin_port=='Davao') echo ' selected="selected"'; ?>Davao</option>
<option value="Dipolog"><? if($delivery_origin_port=='Dipolog') echo ' selected="selected"'; ?>Dipolog</option>
<option value="Dumaguete"><? if($delivery_origin_port=='Dumaguete') echo ' selected="selected"'; ?>Dumaguete</option>
<option value="General Santos"><? if($delivery_origin_port=='General Santos') echo ' selected="selected"'; ?>General Santos</option>
<option value="Iligan"><? if($delivery_origin_port=='Iligan') echo ' selected="selected"'; ?>Iligan</option>
<option value="Iloilo"><? if($delivery_origin_port=='Iloilo') echo ' selected="selected"'; ?>Iloilo</option>
<option value="Ozamis"><? if($delivery_origin_port=='Ozamis') echo ' selected="selected"'; ?>Ozamis</option>
<option value="Puerto Princesa"><? if($delivery_origin_port=='Puerto Princesa') echo ' selected="selected"'; ?>Puerto Princesa</option>
<option value="Roxas"><? if($delivery_origin_port=='Roxas') echo ' selected="selected"'; ?>Roxas</option>
<option value="Surigao"><? if($delivery_origin_port=='Surigao') echo ' selected="selected"'; ?>Surigao</option>
<option value="Tacloban"><? if($delivery_origin_port=='Tacloban') echo ' selected="selected"'; ?>Tacloban</option>
<option value="Tagbilaran"><? if($delivery_origin_port=='Tagbilaran') echo ' selected="selected"'; ?>Tagbilaran</option>
<option value="Toledo"><? if($delivery_origin_port=='Toledo') echo ' selected="selected"'; ?>Toledo</option>
<option value="Zamboanga"><? if($delivery_origin_port=='Zamboanga') echo ' selected="selected"'; ?>Zamboanga</option>
</select></td>
</tr>
<tr>
<td>Port of Destination</td>
<td><select name="delivery_destination_port" id="delivery_destination_port">
<option value="Manila"><? if($delivery_destination_port=='Manila') echo ' selected="selected"'; ?>Manila</option>
<option value="Aklan"><? if($delivery_destination_port=='Aklan') echo ' selected="selected"'; ?>Aklan</option>
<option value="Bacolod"><? if($delivery_destination_port=='Bacolod') echo ' selected="selected"'; ?>Bacolod</option>
<option value="Batangas"><? if($delivery_destination_port=='Batangas') echo ' selected="selected"'; ?>Batangas</option>
<option value="Butuan"><? if($delivery_destination_port=='Butuan') echo ' selected="selected"'; ?>Butuan</option>
<option value="Cagayan"><? if($delivery_destination_port=='Cagayan') echo ' selected="selected"'; ?>Cagayan</option>
<option value="Cebu"><? if($delivery_destination_port=='Cebu') echo ' selected="selected"'; ?>Cebu</option>
<option value="Cotabato"><? if($delivery_destination_port=='Cotabato') echo ' selected="selected"'; ?>Cotabato</option>
<option value="Davao"><? if($delivery_destination_port=='Davao') echo ' selected="selected"'; ?>Davao</option>
<option value="Dipolog"><? if($delivery_destination_port=='Dipolog') echo ' selected="selected"'; ?>Dipolog</option>
<option value="Dumaguete"><? if($delivery_destination_port=='Dumaguete') echo ' selected="selected"'; ?>Dumaguete</option>
<option value="General Santos"><? if($delivery_destination_port=='General Santos') echo ' selected="selected"'; ?>General Santos</option>
<option value="Iligan"><? if($delivery_destination_port=='Iligan') echo ' selected="selected"'; ?>Iligan</option>
<option value="Iloilo"><? if($delivery_destination_port=='Iloilo') echo ' selected="selected"'; ?>Iloilo</option>
<option value="Ozamis"><? if($delivery_destination_port=='Ozamis') echo ' selected="selected"'; ?>Ozamis</option>
<option value="Puerto Princesa"><? if($delivery_destination_port=='Puerto Princesa') echo 'selected="selected"'; ?>Puerto Princesa</option>
<option value="Roxas"><? if($delivery_destination_port=='Roxas') echo ' selected="selected"'; ?>Roxas</option>
<option value="Surigao"><? if($delivery_destination_port=='Surigao') echo ' selected="selected"'; ?>Surigao</option>
<option value="Tacloban"><? if($delivery_destination_port=='Tacloban') echo ' selected="selected"'; ?>Tacloban</option>
<option value="Tagbilaran"><? if($delivery_destination_port=='Tagbilaran') echo ' selected="selected"'; ?>Tagbilaran</option>
<option value="Toledo"><? if($delivery_destination_port=='Toledo') echo ' selected="selected"'; ?>Toledo</option>
<option value="Zamboanga"><? if($delivery_destination_port=='Zamboanga') echo ' selected="selected"'; ?>Zamboanga</option>
</select></td>
</tr>
<tr>
<td>Mode of Service</td>
<td><select name="delivery_service" id="delivery_service">
<option value="Pier-to-Pier"><? if($delivery_service=='Pier-to-Pier') echo 'selected="selected"'; ?>Pier-to-Pier</option>
<option value="Pier-to-Door"><? if($delivery_service=='Pier-to-Door') echo 'selected="selected"'; ?>Pier-to-Door</option>
<option value="Door-to-Pier"><? if($delivery_service=='Door-to-Door') echo 'selected="selected"'; ?>Door-to-Pier</option>
<option value="Van Out"><? if($delivery_service=='Van Out') echo 'selected="selected"'; ?>Van Out</option>
</select></td>
</tr>
<tr>
<td>Payment Arrangement</td>
<td><select name="delivery_payment" id="delivery_payment">
<option value="Cash"><? if($delivery_payment=='Cash') echo 'selected="selected"'; ?>Cash</option>
<option value="With credit line"><? if($delivery_payment=='With credit line') echo 'selected="selected"'; ?>With credit line</option>
</select></td>
</tr>
<tr>
<td>No. of Containers Required</td>
<td><select name="container_nos ." id="container_nos.">
<option value="1"><? if($container_nos. =='1') echo 'selected="selected"'; ?>1</option>
<option value="2"><? if($container_nos. =='2') echo 'selected="selected"'; ?>2</option>
<option value="3"><? if($container_nos. =='3') echo 'selected="selected"'; ?>3</option>
<option value="4"><? if($container_nos. =='4') echo 'selected="selected"'; ?>4</option>
<option value="5"><? if($container_nos. =='5') echo 'selected="selected"'; ?>5</option>
<option value="6"><? if($container_nos. =='6') echo 'selected="selected"'; ?>6</option>
<option value="7"><? if($container_nos. =='7') echo 'selected="selected"'; ?>7</option>
<option value="8"><? if($container_nos. =='8') echo 'selected="selected"'; ?>8</option>
<option value="9"><? if($container_nos. =='9') echo 'selected="selected"'; ?>9</option>
<option value="10"><? if($container_nos. =='10') echo 'selected="selected"'; ?>10</option>
<option value="11"><? if($container_nos. =='11') echo 'selected="selected"'; ?>11</option>
<option value="12"><? if($container_nos. =='12') echo 'selected="selected"'; ?>12</option>
<option value="13"><? if($container_nos. =='13') echo 'selected="selected"'; ?>13</option>
<option value="14"><? if($container_nos. =='14') echo 'selected="selected"'; ?>14</option>
<option value="15"><? if($container_nos. =='15') echo 'selected="selected"'; ?>15</option>
</select></td>
</tr>
<tr>
<td>Container Size</td>
<td><select name="container_size" id="container_size">
<option value="40 Footer"><? if($container_size=='40 Footer') echo 'selected="selected"'; ?>40 Footer</option>
<option value="20 Footer"><? if($container_size=='20 Footer') echo 'selected="selected"'; ?>20 Footer</option>
<option value="10 Footer"><? if($container_size=='10 Footer') echo 'selected="selected"'; ?>10 Footer</option>
</select></td>
</tr>
<tr>
<td>Container Type</td>
<td><select name="container_type" id="container_type">
<option value="Dry Van"><? if($container_type=='Dry Van') echo 'selected="selected"'; ?>Dry Van</option>
<option value="Reefer Van"><? if($container_type=='Reefer Van') echo 'selected="selected"'; ?>Reefer Van</option>
<option value="Fruit Van"><? if($container_type=='Fruit Van') echo 'selected="selected"'; ?>Fruit Van</option>
<option value="Cattle Van"><? if($container_type=='Cattle Van') echo 'selected="selected"'; ?>Cattle Van</option>
</select></td>
</tr>
<tr>
<td>Complete Pick-Up Address</td>
<td><input type="text" name="delivery_pick_up_address" id="delivery_pick_up_address" /></td>
</tr>
<tr>
<td>Contact Person</td>
<td><input type="text" name="delivey_contact_person" id="delivey_contact_person" /></td>
</tr>
<tr>
<td>Contact No. at Place of Pick-Up</td>
<td><input type="text" name="delivery_pick_up_contactnum" id="delivery_pick_up_contactnum" /></td>
</tr>
</table>
<p>
<input name="Reserve" type="submit" id="Reserve" tabindex="160" value="Reserve Now" />
</p>
<input type="hidden" name="MM_insert" value="formsub" />
</form>
</div>
<table align="center" width="1024" height="768" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2">
<img src="images/Reservation_01.gif" width="1024" height="113" alt=""></td>
</tr>
<tr>
<td colspan="2">
<img src="images/Reservation_02.gif" width="1024" height="22" alt=""></td>
</tr>
<tr>
<td>
<img src="images/Reservation_03.gif" alt="" width="152" height="633" border="0" usemap="#Map"></td>
<td>
<img src="images/Reservation_04.gif" width="872" height="633" alt=""></td>
</tr>
</table>
<map name="Map">
<area shape="rect" coords="33,22,116,52" href="home.php">
<area shape="rect" coords="33,57,121,84" href="reservation.php" />
<area shape="rect" coords="31,92,124,120" href="about.php" />
<area shape="rect" coords="30,125,121,154" href="contact.php" />
</map>
</body>
</html>
<?php
mysql_free_result($shipper);
mysql_free_result($consignee);
mysql_free_result($reserve);
mysql_free_result($continfo);
?>
this is the whole code but i dunno where and what to put in the form action i only know how to connect the database and use the textfield as input for my database i dont know the drop down that's my only problem
Last edited by juslai; 10-15-2012 at 02:56 PM ..
10-15-2012, 05:17 PM
PM User |
#7
Senior Coder
Join Date: Jan 2011
Location: Missouri
Posts: 2,383
Thanks: 18
Thanked 350 Times in 349 Posts
In your first post juslai you say
table_delivery has 4 columns delivery_origin, delivery_destination,delivery_payment & delivery_service. This is wrong. The drop down values
are stored in table tbl_reserve along with delivery_pick_up_address, delivey_contact_person, delivery_pick_up_contactnum The following is the code that does it.
Code:
$insertSQL = sprintf("INSERT INTO tbl_reserve (delivery_origin_port, delivery_destination_port, delivery_service, delivery_payment, delivery_pick_up_address, delivey_contact_person, delivery_pick_up_contactnum) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['delivery_origin_port'], "text"),
GetSQLValueString($_POST['delivery_destination_port'], "text"),
GetSQLValueString($_POST['delivery_service'], "text"),
GetSQLValueString($_POST['delivery_payment'], "text"),
GetSQLValueString($_POST['delivery_pick_up_address'], "text"),
GetSQLValueString($_POST['delivey_contact_person'], "text"),
GetSQLValueString($_POST['delivery_pick_up_contactnum'], "int"));
mysql_select_db($database_mysqlconnect, $mysqlconnect);
$Result1 = mysql_query($insertSQL, $mysqlconnect) or die(mysql_error());
The full page code reveled this and once more confirms my decision to stop using dreamweaver those many years ago was a good one.
Users who have thanked sunfighter for this post:
10-15-2012, 11:32 PM
PM User |
#8
New Coder
Join Date: Jul 2012
Location: Philippines
Posts: 35
Thanks: 5
Thanked 0 Times in 0 Posts
uhmmm sunfighter so how to put the drop down values to my database? that is the only thing missing now i want them to be stored in tble_reserve and what is a good editor aside from dreamweaver?
Last edited by juslai; 10-15-2012 at 11:36 PM ..
10-16-2012, 12:39 AM
PM User |
#9
Senior Coder
Join Date: Jan 2011
Location: Missouri
Posts: 2,383
Thanks: 18
Thanked 350 Times in 349 Posts
They should be there. You were looking at the wrong table.
10-16-2012, 02:52 AM
PM User |
#10
New Coder
Join Date: Jul 2012
Location: Philippines
Posts: 35
Thanks: 5
Thanked 0 Times in 0 Posts
oh my first question is really not what i meant. i just want the drop down menu that the user selected to be put inside my database no matter what table they go into tbl_reserve holds all of the data i just want to put all the data in tbl_reserve
10-16-2012, 03:55 PM
PM User |
#11
Senior Coder
Join Date: Jan 2011
Location: Missouri
Posts: 2,383
Thanks: 18
Thanked 350 Times in 349 Posts
You should be able to do this. There are three areas of code that insert data into tables they all start with the line
Code:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "formsub")) {
Just under that is the query string:
Code:
$insertSQL = sprintf("INSERT INTO tbl_consignee (consignee_name, consignee_address, consignee_contactnum) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['consignee_name'], "text"),
GetSQLValueString($_POST['consignee_address'], "text"),
GetSQLValueString($_POST['consignee_contactnum'], "int"));
And
Code:
$insertSQL = sprintf("INSERT INTO tbl_shipper (shipper_name, shipper_address, shipper_email, shipper_contactnum) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['shipper_name'], "text"),
GetSQLValueString($_POST['shipper_address'], "text"),
GetSQLValueString($_POST['shipper_email'], "text"),
GetSQLValueString($_POST['shipper_contactnum'], "int"));
Change that or do it twice to also keep the other two tables up to date. Just make sure tbl_reserve has the columns it needs to hold the data.
Good luck to you sir. Hope things work out.
Users who have thanked sunfighter for this post:
10-17-2012, 12:58 AM
PM User |
#12
New Coder
Join Date: Jul 2012
Location: Philippines
Posts: 35
Thanks: 5
Thanked 0 Times in 0 Posts
uhmmm sunfighter sorry for being a newbie but i have no problem with consignee and shipper values they insert into database without any problems the thing im having trouble with is the slect(list/menu) values that are chosen by the user they wont get inserted into my table for the
Code:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "formsub")) {
$insertSQL = sprintf("INSERT INTO tbl_container_info (container_nos., container_size, container_type) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['container_nos.'], "int"),
GetSQLValueString($_POST['container_size'], "text"),
GetSQLValueString($_POST['container_type'], "text"));
Code:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "formsub")) {
$insertSQL = sprintf("INSERT INTO tbl_reserve (delivery_origin_port, delivery_destination_port, delivery_service, delivery_payment, delivery_pick_up_address, delivey_contact_person, delivery_pick_up_contactnum) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['delivery_origin_port'], "text"),
GetSQLValueString($_POST['delivery_destination_port'], "text"),
GetSQLValueString($_POST['delivery_service'], "text"),
GetSQLValueString($_POST['delivery_payment'], "text"),
GetSQLValueString($_POST['delivery_pick_up_address'], "text"),
GetSQLValueString($_POST['delivey_contact_person'], "text"),
GetSQLValueString($_POST['delivery_pick_up_contactnum'], "int"));
they wont work
Code:
GetSQLValueString($_POST['container_nos.'], "int"),
GetSQLValueString($_POST['container_size'], "text"),
GetSQLValueString($_POST['container_type'], "text"));
GetSQLValueString($_POST['delivery_origin_port'], "text"),
GetSQLValueString($_POST['delivery_destination_port'], "text"),
GetSQLValueString($_POST['delivery_service'], "text"),
GetSQLValueString($_POST['delivery_payment'], "text"),
they are from a drop down menu i created i want them to be inserted into database
Code:
GetSQLValueString($_POST['delivery_pick_up_address'], "text"),
GetSQLValueString($_POST['delivey_contact_person'], "text"),
GetSQLValueString($_POST['delivery_pick_up_contactnum'], "int"));
they are from a text field that a user has to type all of these go to tbl_reserve and tbl_container_info
but when i finish the form and click reserve button only tbl_shipper and tbl_consignee gets updated
Last edited by juslai; 10-17-2012 at 01:00 AM ..
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 01:37 PM .
Advertisement
Log in to turn off these ads.