Sunday, 15 March 2015

php mysql insert from array item -



php mysql insert from array item -

my array item construction like

title: "", createdby: "", pointerset:[ {position: 1, catagoryid: 1, caption: "", imageurl: ""} {position: 1, catagoryid: 1, caption: "", imageurl: ""} {position: 1, catagoryid: 1, caption: "", imageurl: ""} ]

now if url nail item array info how can insert pointerset array item in database.

my database info goes 2 table

table 1

title: "", createdby: "",

then table two

pointerset:[ {position: 1, catagoryid: 1, caption: "", imageurl: ""} {position: 1, catagoryid: 1, caption: "", imageurl: ""} {position: 1, catagoryid: 1, caption: "", imageurl: ""} ]

i using method.

in table 1 can insert table 2 how can insert .

$_get['pointerset'] = array( array(position='', catagoryid='',caption='',imageurl=''), array(position='', catagoryid='',caption='',imageurl=''), array(position='', catagoryid='',caption='',imageurl='') );

here's how can using pdo prepared statement

$stmt = $pdo->prepare("insert pointertable (position, categoryid, caption, imageurl) values(:position, :categoryid, :caption, :imageurl)"); foreach ($array['pointerset'] $pointer) { $stmt->execute($pointer); }

php mysql arrays

No comments:

Post a Comment