Login   Register  
PHP Classes
elePHPant
Icontem

File: examples/demo_05.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_05.php  >  Download  
File: examples/demo_05.php
Role: Example script
Content type: text/plain
Description: Example 5 - Shows a advanced query (with substr)
Class: HTML SQL
Parse and extract information from HTML using SQL
Author: By
Last change:
Date: 2006-05-08 06:26
Size: 937 bytes
 

Contents

Class file image Download
<?php

    
/*
    ** htmlSQL - Example 5
    **
    ** Shows a advanced query (with substr)
    */

    
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/links.htm')){
        print 
'Error while connecting: ' $wsql->error;
        exit;
    }
    
    
/* execute a query:
       
       This query returns all links of an document that not start with / 
       ( / = internal links)
    */
    
if (!$wsql->query('SELECT * FROM a WHERE substr($href,0,1) != "/"')){
        print 
"Query error: " $wsql->error
        exit;
    }

    
// fetch results as object and format as HTML links:
    
foreach($wsql->fetch_objects() as $obj){
    
        print 
'<a href="'.$obj->href.'">'.$obj->text.'</a><br/>';
        print 
"\n";
        
    }
    
?>