mysql - Putting an array into a table with SimpleXMLobject using php -
array ( [0] => array ( [title] => simplexmlelement object ( [0] => aa ) [pubdate] => simplexmlelement object ( [0] => aa ) [link] => simplexmlelement object ( [0] => aa ) ) [1] => array ( [title] => simplexmlelement object ( [0] => bb ) [pubdate] => simplexmlelement object ( [0] => bb ) [link] => simplexmlelement object ( [0] => bb ) )
i want put table has (title, pubdate, link) columns. confused how put mysql table when there simplexmlelement object , [0]
in way. if not in way, able put table, because there , have never seen them before, terribly confused.
this have tried:
foreach($string $item){ insert table (title, pubdate, link)values($item->title, $item->pubdate, $item->link) }
fyi how made array:
$string = $con->channel->item; $table = array(); foreach ($string $item) { $table[] = array( 'title' => $item->title, 'pubdate' => $item->pubdate, 'link' => $item->link ); }
you can't insert in database. implode first array.
try this:
$string = $con->channel->item; $table = array(); foreach ($string $item) { $sql = mysqli_query("insert table (title, pubdate, link)values('$item->title', '$item->pubdate', '$item->link')"; ); }
Comments
Post a Comment