CincoPistolero Posted July 3, 2008 Share Posted July 3, 2008 I've been trying to follow an online tutorial on how to load arrays into mulitple rows using checkboxes in a db. I am able my array created. I am able to pass some IDs to my confirmation page. But I can't get the code to actually enter it in the DB and I'm not getting any errors on my page. On my confirmation page, I confirm that my POST is sending data, by: echo "<pre>"; print_r($_POST); echo "</pre>\n" this results in: Array ( [optPricesID] => Array ( [0] => 35 [1] => 37 [2] => 39 ) ) Below is the code I have that tries to take this array and put it into a db. I do have the connection php code to the database in place at the top of the page. Any and all help is appreciated. $tsID=3; function insert_skills($tsID, $optPricesID) { purge_lookup("testSpecsOpt", $tsID); $query = create_checkbox_query($optPricesID, "testSpecsOpt", $tsID); mysql_query($query); } function purge_lookup($table, $tsID) { $q = "DELETE FROM testSpecsOpt, WHERE testSpecsID = '$tsID'"; mysql_query($q); } function create_checkbox_query($arr, $table, $tsID) { $q = "INSERT INTO testSpecsOpt (testSpecsID, optPricesID ) VALUES"; foreach ($arr as $check) { $q .= " ( $tsID , $check )" . ","; } return substr($q, 0, -1); } Link to comment https://forums.phpfreaks.com/topic/113140-solved-trying-to-upload-array-into-a-mysql-db-trying-is-operative-word/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.