Page 1 of 1

insert array and none array?[SOLVE]

Posted: Mon Jul 30, 2012 5:33 am
by jayson.ph
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

Re: insert array and none array?

Posted: Mon Jul 30, 2012 8:51 am
by social_experiment
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?

Re: insert array and none array?

Posted: Mon Jul 30, 2012 9:30 pm
by jayson.ph
ah no, every text-filed value, there is an specific column values.

Re: insert array and none array?

Posted: Tue Jul 31, 2012 6:37 am
by social_experiment
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

Re: insert array and none array?[SOLVE]

Posted: Thu Aug 02, 2012 5:01 am
by jayson.ph
Thank you for all reply, and now i change the flow and now i get it solve.. Thanks a lot.