troubleshooting Question

multiple items being inserted as one item

Avatar of peter_coop
peter_coopFlag for United Kingdom of Great Britain and Northern Ireland asked on
Web DevelopmentPHPMySQL Server
15 Comments1 Solution326 ViewsLast Modified:
I am trying to accept multiple items from a form and when they reach php for processing, split the items and treat them as seperate items to insert into db. What is happening at the moment, is that the items are being inserted into the db as one item. For example, i enter item1,item2,item3. This is being inserted into the db in one column. all three items in one column. How can I correct my code to achieve this. Many thanks
foreach($_POST['BRV-brtrv-boxnumber'] as $i=>$value){
$_POST['BRV-brtrv-boxnumber'][$i]=mysql_real_escape_string($value);
}
$boxnumber = implode( ',', $_POST['BRV-brtrv-boxnumber']);

$query = 'INSERT INTO `act` (`service`, `activity`, `department`, `company`,  `address`, `user`, `item`, `destroydate`, `date`, `new`)
         VALUES (\''.$service.'\', \''.$activity.'\', \''.$department.'\', \''.$company.'\', \''.$address.'\', \''.$authorised.'\', \''.strtoupper($boxnumber).'\', NULL, NOW(), \''.$new.'\');';
mysql_query($query) or die('Error, query failed');
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 15 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros