Insert multiple checkbox values
-
Hello,
I am trying to insert multiple checkbox values in my dataBase with the function insert() of WordPress, but it don’t work same when I use a SQL request. Although my table exist I really don’t see where is the problem…
<form name="orderform" method="post" > <table id="Tableau" style="border-collapse: collapse;" id="tableauS" border="1"><tr><th>Attributs</th><th>Choix</th></tr></html> <?php $resultat= $wpdb->get_results("SELECT * from wp_frm_fields ",ARRAY_N); // lancement de la requete foreach ($resultat as $post) { echo '<tr><td>'.$post[2].'</td>'; echo"<td><center><input type='checkbox' name='choixP' value='".$post[0]."'></center></td>"; } ?> <html></tr> <input type="submit" name="sub" value="submit"> </table></form> <?php if(isset($_POST['sub'])) { global wpdb; $checkbox1=$_POST['choixP']; $chk=""; foreach($checkbox1 as $chk1) { $chk = $chk1; $wpdb->insert( 'wp_choix_attributs_liste', array('att_id'=>$chk), array(%s) ); -------- Dont Work too----------- $query = "INSERT INTO wp_choix_attributs_liste (att_id) VALUES ('".$chk."')"; mysql_query($query) or die(mysql_error()); --------------------------------- } }
The topic ‘Insert multiple checkbox values’ is closed to new replies.