Login   Register  
PHP Classes
elePHPant
Icontem

File: examples/demo_07.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of J.  >  HTML SQL  >  examples/demo_07.php  >  Download  
File: examples/demo_07.php
Role: Example script
Content type: text/plain
Description: Example 7 - Shows a complex query
Class: HTML SQL
Parse and extract information from HTML using SQL
Author: By
Last change:
Date: 8 years ago
Size: 960 bytes
 

Contents

Class file image Download
<?php

    
/*
    ** htmlSQL - Example 7
    **
    ** Shows a complex query
    */

    
include_once("../snoopy.class.php");
    include_once(
"../htmlsql.class.php");
    
    
$wsql = new htmlsql();
    
    
// connect to a URL
    
if (!$wsql->connect('url''http://codedump.jonasjohn.de/browse/lang/php/')){
        print 
'Error while connecting: ' $wsql->error;
        exit;
    }
    
    
/* execute a query:
       
       This query searches all links where the URL starts with /snippets and the text starts with 
       "array_" => so all links to array functions will be returned
    */
    
if (!$wsql->query('SELECT * FROM a WHERE preg_match("/^\/snippets/i", $href) and preg_match("/^array_/i", $text)')){
        print 
"Query error: " $wsql->error
        exit;
    }

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