Wie füge ich ausrangierte Website-Daten in die Datenbank ein?

Ich möchte speichern:

ProduktnameKategorieUnterkategoriePreisProduktunternehmen.

In meiner Tabelle heißt products_data mit Feldnamen wie PID, product_name, category, subcategory, product_price und product_company.

ich benutzecurl_init() Funktion in PHP zum ersten Verschrotten der Website-URL, als nächstes möchte ich Produktdaten in meiner Datenbanktabelle speichern. Folgendes habe ich bisher dafür getan:

$sites[0] = 'http://www.babyoye.com/';

foreach ($sites as $site)
{
    $ch = curl_init($site);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $html = curl_exec($ch);

    $title_start = '<div class="info">';

    $parts = explode($title_start,$html);
    foreach($parts as $part){
        $link = explode('<a href="/d/', $part);

        $link = explode('">', $link[1]);
        $url = 'http://www.babyoye.com/d/'.$link[0];

        // now for the title we need to follow a similar process:

        $title = explode('<h2>', $part);

        $title = explode('</h2>', $title[1]);

        $title = strip_tags($title[0]);

        // INSERT DB CODE HERE e.g.

        $db_conn = mysql_connect('localhost', 'root', '') or die('error');
        mysql_select_db('babyoye', $db_conn) or die(mysql_error());

        $sql = "INSERT INTO products_data(PID, product_name) VALUES ('".$url."', '".$title."')"

        mysql_query($sql) or die(mysql_error()); 

    }
}

Ich bin wenig verwirrt mit dem Datenbankteil, wie man Daten in Tabelle einfügt. Irgendeine Hilfe?

Antworten auf die Frage(1)

Ihre Antwort auf die Frage