[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 281
  • Last Modified:

Dynamic Drop Down insert PHP

Hi Experts,

Ive got a probably rather simple question for you guys.

How do i post the data from a drop down box created dynamicly and post the information selected to the next page and then insert the data into my database..

both pages of code are attached..

am i doing something wrong here?

many thanks
//////////////////// FORM FOR GETTING THE DYNAMIC DROP DOWN ////////////////

<?php
$sql = "SELECT customer_name FROM customer ORDER BY title";
$rs = mysql_query($sql);
echo $sql;
while($row = mysql_fetch_array($rs)) {
  echo "<option value=\"".$row['customer_name']."\">" . $row['customer_name'] . "</option>"; 

}
?>
</select></td>
</tr>
<tr>
<td bgcolor="#ffffff">Mobile Number</td>
<td bgcolor="#ffffff">:</td>
<td bgcolor="#ffffff"><input type ="text" size="20" maxlength="15" name="mobile_number"> </td>
</tr>
<tr>
<td bgcolor="#ffffff">Month of Connection</td>
<td bgcolor="#ffffff">:</td>
<td bgcolor="#ffffff"><input type ="text" size="20" maxlength="30" name="month_conn"> </td>
</tr>
<tr>
<td bgcolor="#ffffff">Contract Start Date</td>
<td bgcolor="#ffffff">:</td>
<td bgcolor="#ffffff"><input type ="text" size="20" maxlength="30" name="start_contract"> </td>
</tr>
<tr>
<td bgcolor="#ffffff">Contract End Date</td>
<td bgcolor="#ffffff">:</td>
<td bgcolor="#ffffff"><input type ="text" size="20" maxlength="30" name="end_contract"> </td>
</tr>
<tr>
<td bgcolor="#ffffff">IMEI</td>
<td bgcolor="#ffffff">:</td>
<td bgcolor="#ffffff"><input type="text" size="20" maxlength="40" name="IMEI"></td>
</tr>
<td bgcolor="#ffffff">Type Of Account (Con/Upg)</td>
<td bgcolor="#ffffff">:</td>
<td bgcolor="#ffffff"><input type ="text" size="20" maxlength="3" name="type_acc">
</td>
</tr>
<tr>
<td bgcolor="#ffffff">Account Number</td>
<td bgcolor="#ffffff">:</td>
<td bgcolor="#ffffff"><input type="text" size="20" maxlength="20" name="account_number"></td>
</tr>
<tr>
<td bgcolor="#ffffff">Term</td>
<td bgcolor="#ffffff">:</td>
<td bgcolor="#ffffff"><input type="text" size="20" maxlength="15" name="term"></td>
</tr>
<tr>
<td bgcolor="#ffffff">Tariff</td>
<td bgcolor="#ffffff">:</td>
<td bgcolor="#ffffff"><input type="text" size="20" maxlength="25" name="tariff"></td>
</tr>
<tr>
<td bgcolor="#ffffff"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</td>
</form>

///////////////// THE INSERT PAGE ////////////////


<?php
session_start();
ob_start();
?>
<?php 
error_reporting(E_ALL);

$customer_name = $_POST['ddlCompanies'];
$mobile_number = $_POST['mobile_number'];
$month_conn = $_POST['month_conn'];
$start_contract = $_POST['start_contract'];
$end_contract = $_POST['end_contract'];
$IMEI = $_POST['IMEI'];
$type_acc = $_POST['type_acc'];
$account_number = $_POST['account_number'];
$term = $_POST['term'];
$tariff = $_POST['tariff'];
include 'myphp.php';




//insert details gatherd from registertation form into the datbase

$sql="INSERT INTO customer_details(customer_name, mobile_number, month_conn, start_contract, end_contract, IMEI, type_acc, account_number, term, tariff)VALUES('".$customer_name."', '".$mobile_number."', '".$month_conn."', '".$start_contract."', '".$end_contract."', '".$IMEI."', '".$type_acc."', '".$account_number."', '".$term."', '".$tariff."')";
$result=mysql_query($sql);

if($result){
	echo"Successful";
	echo"<BR>";
	echo"<a href='home.php'>Back to admin home</a>";
}
else{
	echo "ERROR";
}
mysql_close();

?>

Open in new window

0
NeoAshura
Asked:
NeoAshura
  • 3
  • 3
1 Solution
 
mankowitzCommented:
where's the beginning of the select tag. All you posted was this:

<?php
$sql = "SELECT customer_name FROM customer ORDER BY title";
$rs = mysql_query($sql);
echo $sql;
while($row = mysql_fetch_array($rs)) {
  echo "<option value=\"".$row['customer_name']."\">" . $row['customer_name'] . "</option>";

}
?>
</select>


Does it generate the dropdown box for you?
0
 
NeoAshuraAuthor Commented:
apologies, here you go.


<select id="ddlCompanies">
<?php
$sql = "SELECT customer_name FROM customer ORDER BY title";
$rs = mysql_query($sql);
echo $sql;
while($row = mysql_fetch_array($rs)) {
  echo "<option value=\"".$row['customer_name']."\">" . $row['customer_name'] . "</option>";

}
?>
</select>
0
 
NeoAshuraAuthor Commented:
problem solved was a stupid error i didn't give my select box a name.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
mankowitzCommented:
change it to <select name="ddlCompanies">
0
 
mankowitzCommented:
oops. you got it.
0
 
NeoAshuraAuthor Commented:
own problem solved.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now