buchberg Posted August 27, 2012 Share Posted August 27, 2012 Apache/2.2.21 (Win32) PHP/5.3.5 I've tried this for awhile, and it is killing me. Any help would be appreciated. All I want to do is take checkbox input (from a form), sent to to the server side (?????). Everything is on a local machine. Im a noob, so be nice please. I'm posting to MySQL, but the value shows the word (Array). I'm having trouble with the 'foreach' function of an array. Any help is appreciated. I have (3) of these arrays. If I can get one, the rest should be the same format. $bid_status = $_POST['bid_status']; var_dump($bid_status); foreach ($_POST['bid_status'] =>$v_bs ??????? No idea. I want to post the array value into the below sql 'INSERT into $table_name..... (bid_status) would be my column name for the database-it is there and connecting. However, VALUES ($_POST['bid_status']) posts the word (Array). I want the checkbox values. There are 4 of them similar to below. Thank you in advance, and have a good day.... <INPUT TYPE=\"checkbox\" NAME=\"bid_status[]\" Value=\"spec\"><small><small>CMS</small></small> $db_name="projects_bid_dates"; $table_name="project_status"; $connection=mysql_connect("localhost", "user", "password") or die (mysql_error()); $db=mysql_select_db($db_name, $connection) or die (mysql_error()); //line 34 $sql="INSERT INTO $table_name (project_name, bid_date, bid_status, engineer, contractor, equipment, comments) VALUES ('$_POST[project_name]','$_POST[bid_date]', '$_POST[bid_status]','$_POST[engineer]', '$_POST[contractor]', '$_POST[equipment]', '$_POST[comments]')"; $result=mysql_query($sql, $connection) or die (mysql_error()); Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted August 27, 2012 Share Posted August 27, 2012 Implode the array http://php.net/manual/en/function.implode.php Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 28, 2012 Share Posted August 28, 2012 Typically rather than imploding an array's values and storing it in one row, you would have a new row for each value, and link them back to the parent row with an ID. You also have the foreach() syntax wrong in your example. foreach($array AS $key=>$value){} Quote Link to comment Share on other sites More sharing options...
buchberg Posted August 30, 2012 Author Share Posted August 30, 2012 Thank you very much. I appreciate the support. Take it easy..... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.