insert array and none array?[SOLVE]
Posted: Mon Jul 30, 2012 5:33 am
hi all,
i just creating a partial code for my item maintenance.. i have 3 text field and the 2 textfield are none array while 1 textfield is array(itemdesc)and i have a button to add a multiple input text. and now i get lost to insert the following when i insert them together since they are not same element.
please advice me if what should i do to insert both together the 3 textfield.
thanks
i just creating a partial code for my item maintenance.. i have 3 text field and the 2 textfield are none array while 1 textfield is array(itemdesc)and i have a button to add a multiple input text. and now i get lost to insert the following when i insert them together since they are not same element.
please advice me if what should i do to insert both together the 3 textfield.
Code: Select all
$cat_name = $_POST['cat_name'];
$product_name = $_POST['product_name'];
$itemdesc = $_POST['itemdesc'];
if($itemdesc)
{
foreach($itemdesc as $desc)
{
$mydesc[] = $desc;
}
}
$value = "('".implode("'), ('",$mydesc)."')";
$sql = "INSERT INTO tbl_itemdescription(item_desc,product_name,cat_id) VALUES".$value.",("$product_name","$cat_name")";
$result = mysql_query($sql)or die('query error. $sql' .mysql_error());thanks