i have problem query. indeed, want truncate table , insert data same table.
my problem : when execute these 2 queries insert records 1 row , don't know why. when execute insert query without truncate before works fine. can combine truncate , insert ?
thanks
here code :
<?php $base = mysql_connect ("***", "***", "***"); mysql_select_db ('***', $base) ; $vider = "truncate table drag"; mysql_query($vider); // accept json parameter (and un-quote string if needed) $p = stripslashes($_request['p']); // decode json object (it shouldn't decoded associative array) $arr = json_decode($p); // open loop through each array element foreach ($arr $p){ // set id, row index , cell index $id = $p[0]; $row = $p[1]; $cell = $p[2]; // instead of print, can store accepted parameteres database print "id=$id row=$row cell=$cell<br>"; $ajout = "insert drag values('','$id','$row','$cell')"; mysql_query($ajout); mysql_close($base); } ?>
i think should remove mysql_close foreach() loop.
you closing database connection after first insert. next queries nothing
Comments
Post a Comment