php - using implode to insert values into database table columns -
i using php implode insert values, fetched array of input fields, database table column. works fine me:
$insert_row =mysql_query("insert activityproduct (ideal) values (" . implode('),(', $_post["ideal"]) . ")");
i'd insert values, fetched 2 different array of input fields, 2 database table columns. below code produces , error:
$insert_row =mysql_query("insert activityproduct (aid,ideal) values (" . implode('),(', $_post["act"]) . " ," . implode('),(', $_post["ideal"]) . ")");
i'd express 2 arrays, in insert statement, as, e.g: (10,21),(20,31),(30,41) , not (10),(21),(20),(31),(30),(41)
any idea on how go this, highly appreciated.
use may you
$ideal=implode('),(', $_post["ideal"]); $act=implode('),(', $_post["act"]); $insert_row =mysql_query("insert activityproduct (ideal) values (" .mysql_real_escape_string($ideal). ")"); $insert_row =mysql_query("insert activityproduct (aid,ideal) values (" .mysql_real_escape_string($ideal). " ," .mysql_real_escape_string($act). ")");
and try use mysqli
insted of mysql
.
in mysqli
$insert_row = mysqli->prepare("insert activityproduct (ideal) values ($ideal)"); $insert_row =mysql_query("insert activityproduct (aid,ideal) values ($ideal,$act)");
Comments
Post a Comment