Hi? im just a beginner in php i just want to ask how to insert a data into a table from a dropdown list. I have concatenate the itemid and description to form the dropdown list. But when i viewed my item_table the itemid and description columns are null. can you help me with this..
this is my php code for the dropdown list...
<?php
$query = "SELECT CONCAT(itemid,' ', '-',' ', description) AS Item FROM item_table";
$result = mysql_query($query) or die(mysql_error());
$dropdown = "<SELECT CONCAT(itemid,' ' '-',' ', description) AS Item FROM item_table>";
while($row = mysql_fetch_assoc($result)) {
$dropdown .= "\r\n<option value='{$row['Item']}'>{$row['Item']}</option>";
}
$dropdown .= "\r\n</select>";
echo $dropdown;
?>
this my code for inserting data into the item_table...
<?php
if(isset($_POST ['submit']))
{
$itemid = $_POST['itemid'];
$description = $_POST['description'];
$datein = $_POST['datein'];
$qtyin = $_POST['qtyin'];
$unitprice = $_POST['unitprice'];
$unit = $_POST['unit'];
$category = $_POST['category'];
$empid = $_POST['empid'];
$message ='';
if(($itemid && $description == "")||($itemid && $description == null))
{
header("location:IncomingEntry.php?msg=Incorrect");
exit();
}
else
{
$link = mysql_connect('localhost', 'root', '') or die(mysql_error());
$db_selected = mysql_select_db('inventory', $link);
$message='';
$query = "INSERT INTO incoming_table (itemid , description, datein, qtyin, unitprice, unit, category, empid) VALUES ('".$itemid."', '".$description."', '".$datein."', '".$qtyin."', '".$unitprice."', '".$unit."', '".$category."', '".$empid."')";
if (!mysql_query($query,$link))
{
die('Error: ' . mysql_error());
}
header("location: IncomingEntry.php?msg=1 record added");
}
}
?>
:'(