I Write Code with $wpdb Variable to store data in the database..
In The following code , Get Name , Price ,.. From other website with Curl(curl code isn't here now)... every day Curl Get Name , Price ,..
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),
);
}
}
from example.com and then save in the database table(wp_price)... In The following code every day insert new data value in to the wp_price table and dosen't Save New values replace the previous values ... I want New values replace the previous values .. (namely:today .. liveprice = '2000' , tomorrow liveprice = '2500' ,../
in the follwoing code "$wpdb->insert( $wpdb->prefix" running insert new value of field every run curl example:
title |liveprice|changing|topest|lowest|time
coin | 25$ | 50% | 25$ | 15$ | 20/5/2014 coin | 25$ | 50% | 25$ | 15$ | 21/5/2014 coin | 24$ | 50% | 24$ | 13$ | 22/5/2014
But I don't want add new value of fields .
I want replace new value with previous value.. example
first run insert data ..
title |liveprice|changing|topest|lowest|time
coin | 25$ | 50% | 25$ | 15$ | 20/5/2014
and second run .Replace new values instead previous Values and dont add new row of the new values
title |liveprice|changing|topest|lowest|time
coin | 28$ | 50% | 28$ | 15$ | 21/5/2014
`foreach($table_rows as $tr) { // foreach row
$row = $tr->childNodes;
if($row->item(0)->tagName != 'tblhead') { // avoid headers
$wpdb->insert( $wpdb->prefix . 'fafa',
array(
'title' => trim($row->item(0)->nodeValue) ,
'liveprice' => trim($row->item(2)->nodeValue) ,
'changing' => trim($row->item(4)->nodeValue) ,
'lowest' => trim($row->item(6)->nodeValue) ,
'topest' => trim($row->item(8)->nodeValue) ,
'time' => trim($row->item(10)->nodeValue) ),
array(
'%s',
'%s',
'%s',
'%s',
'%s',
'%s'
) );
$wpdb->update( $wpdb->prefix . 'fafa',
array(
'title' => trim($row->item(0)->nodeValue) ,
'liveprice' => trim($row->item(2)->nodeValue) ,
'changing' => trim($row->item(4)->nodeValue) ,
'lowest' => trim($row->item(6)->nodeValue) ,
'topest' => trim($row->item(8)->nodeValue) ,
'time' => trim($row->item(10)->nodeValue) ),
array(
'%s',
'%s',
'%s',
'%s',
'%s',
'%s'
) );
}
}`
I Want update data evey day (i.e delete last day data and insert new data )