insert array and none array?[SOLVE]

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

Post Reply
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

insert array and none array?[SOLVE]

Post 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
Last edited by jayson.ph on Thu Aug 02, 2012 5:01 am, edited 1 time in total.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: insert array and none array?

Post 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?
“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
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

Re: insert array and none array?

Post by jayson.ph »

ah no, every text-filed value, there is an specific column values.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: insert array and none array?

Post 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
“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
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

Re: insert array and none array?[SOLVE]

Post by jayson.ph »

Thank you for all reply, and now i change the flow and now i get it solve.. Thanks a lot.
Post Reply