tags:

views:

143

answers:

1

I pull a data from other website by using curl but how to store in my local database.

$url = 'http://sample.com/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
echo $data;

I just want post some categories and sample of data.

+2  A: 

right.

well, i asume you're using mysql as database. if you have allready set up your database including a table owning a blob or text formatted field you can easily store the data there by sending a query like:

"INSERT INTO mytable SET curlData='".$data."';"

with PHP you can connect to your DB via mysql_connect() after selecting the desired database with mysql_select_db() you can start sending queries to the db.

use the mysql_connect() php-native-call to do so.

I hope i was helpful now ;-)

by the way, check out the php-mysql manual for further information.

helle
While you have accurately listed the technologies s/he *could* use, you're also just repeating the tags s/he applied to the question. To gain up-votes you might want to say *how* s/he could use php-mysql to achieve this.
David Thomas
better this way ? ;-)
helle
As I want insert only product name,price,image etc , how to sort it. Because $data gave whole sitepage contents.
Deepali
try to parse the data by searching i.e. css-ids or something where your desired content can be found in the answer-code. use regular expressions, to have performance or simply stristr().it would be helpful if you come out with some details of your problem, because this problem has very many facetts ;-)
helle
@helle, yup; better that way (+1) =)
David Thomas