Login   Register  
PHP Classes
elePHPant
Icontem

File: examples/demo_02.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_02.php  >  Download  
File: examples/demo_02.php
Role: Example script
Content type: text/plain
Description: Example 2 - Shows a simple query and the "href as url" usage
Class: HTML SQL
Parse and extract information from HTML using SQL
Author: By
Last change:
Date: 2006-05-08 06:13
Size: 898 bytes
 

Contents

Class file image Download
<?php

    
/*
    ** htmlSQL - Example 2
    **
    ** Shows a simple query and the "href as url" usage
    */
    
    
include_once("../snoopy.class.php");
    include_once(
"../htmlsql.class.php");
    
    
$wsql = new htmlsql();
    
    
// connect to a file
    
if (!$wsql->connect('file''demo_data.htm')){
        print 
'Error while connecting: ' $wsql->error;
        exit;
    }
    
    
/* execute a query:
       
       This query extracts all links from the document
       and just returns href (as url) and text
    */
    
if (!$wsql->query('SELECT href as url, text FROM a')){
        print 
"Query error: " $wsql->error
        exit;
    }

    
// show results:
    
foreach($wsql->fetch_array() as $row){
    
        print 
"Link-URL: " $row['url'] . "\n";
        print 
"Link-Text: " trim($row['text']) . "\n\n";
        
    }
    
?>