I warite script to extract price and name from website with foreach loop.
foreach($table_rows as $tr) { // foreach row
$row = $tr->childNodes;
if($row->item(0)->tagName != 'tblhead') { // avoid headers
$data[] = array(
$trip ['Name' ]= trim($row->item(0)->nodeValue),
$trip['LivePrice'] = trim($row->item(2)->nodeValue),
$trip ['Changing']= trim($row->item(4)->nodeValue),
$trip ['Lowest']= trim($row->item(6)->nodeValue),
$trip['Topest']= trim($row->item(8)->nodeValue),
$trip['Time']= trim($row->item(10)->nodeValue),
);
}
}
and then save they in to the database with mysql (no mysqli or pdo) . but only save one record ، If the 5 column provided .
and after each refresh the page save Previous record (i.e repetitive recod)
please see following .
in the database:
id | name | liveprice | changing | lowest | topest | time
1 | lg | 25500 | 05 | 22500 | 22500 | 2014
2 | lg | 25500 | 05 | 22500 | 22500 | 2014
3 | lg | 25500 | 05 | 22500 | 22500 | 2014
database code and php for store data in to the database
$article = array ();
mysql_select_db ( "coin", $con );
"CREATE TABLE `Dadoo`(id INT NOT NULL AUTO INCREMENT,PRIMARY KEY(id),`title` VARCHAR(255),`liveprice` VARCHAR(255),`changing` VARCHAR(255),`lowest` VARCHAR(255),`topest` VARCHAR(255) ENGINE=MyISAM";
$debugquery = mysql_query("INSERT INTO `Dadoo`(title,liveprice,changing,lowest,topest,time) VALUES ('".$trip['Name']."','".$trip['LivePrice']."','".$trip['Changing']."','".$trip['Lowest']."','".$trip['Topest']."','".$trip['Time']."')");
if (!$debugquery)
{
die(mysql_error());
}
now how can I save multidimensional array in the database?