PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
jayson.ph
Forum Contributor
Posts: 165 Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:
Post
by jayson.ph » 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.
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
Last edited by
jayson.ph on Thu Aug 02, 2012 5:01 am, edited 1 time in total.
social_experiment
DevNet Master
Posts: 2793 Joined: Sun Feb 15, 2009 11:08 am
Location: .za
Post
by social_experiment » Mon Jul 30, 2012 8:51 am
jayson.ph wrote: please advice me if what should i do to insert both together the 3 textfield.
do you wish to insert all the data from the 3 text fields into a single column?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
jayson.ph
Forum Contributor
Posts: 165 Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:
Post
by jayson.ph » Mon Jul 30, 2012 9:30 pm
ah no, every text-filed value, there is an specific column values.
social_experiment
DevNet Master
Posts: 2793 Joined: Sun Feb 15, 2009 11:08 am
Location: .za
Post
by social_experiment » Tue Jul 31, 2012 6:37 am
I see;
i'm afraid i still don't understand what you have in mind, if you could perhaps give an example i might be able to assist
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
jayson.ph
Forum Contributor
Posts: 165 Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:
Post
by jayson.ph » Thu Aug 02, 2012 5:01 am
Thank you for all reply, and now i change the flow and now i get it solve.. Thanks a lot.