PHP Classes

File: examples/demo_06.php

Recommend this page to a friend!
  Classes of J.   HTML SQL   examples/demo_06.php   Download  
File: examples/demo_06.php
Role: Example script
Content type: text/plain
Description: Example 6 - Show how to connect to a string
Class: HTML SQL
Parse and extract information from HTML using SQL
Author: By
Last change:
Date: 18 years ago
Size: 887 bytes
 

Contents

Class file image Download
<?php

   
/*
    ** htmlSQL - Example 6
    **
    ** Show how to connect to a string
    */

   
include_once("../snoopy.class.php");
    include_once(
"../htmlsql.class.php");
   
   
   
$some_html = '<a href="link1.htm">link1</a> <b>foobar</b> ';
   
$some_html .= '<a href="link2.htm">link2</a> <hr/>';
   
   
$wsql = new htmlsql();
   
   
// connect to a string
   
if (!$wsql->connect('string', $some_html)){
        print
'Error while connecting: ' . $wsql->error;
        exit;
    }
   
   
/* execute a query:
      
       This query returns all links of the given HTML
    */
   
if (!$wsql->query('SELECT * FROM a')){
        print
"Query error: " . $wsql->error;
        exit;
    }

   
// fetch results as array and output them:
   
foreach($wsql->fetch_array() as $row){
   
       
print_r($row);
       
    }
   
?>