diff options
Diffstat (limited to 'examples/demo_10.php')
-rwxr-xr-x | examples/demo_10.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/examples/demo_10.php b/examples/demo_10.php new file mode 100755 index 0000000..961a0a8 --- /dev/null +++ b/examples/demo_10.php @@ -0,0 +1,55 @@ +<?php
+
+ /*
+ ** htmlSQL - Example 10
+ **
+ ** Shows how to use the "isolate_content" function
+ */
+
+ 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/')){
+ print 'Error while connecting: ' . $wsql->error;
+ exit;
+ }
+
+ /*
+ ** The isolate_content functions works like the select function,
+ ** but you can specify custom HTML parts, the content between
+ ** these two strings will be used for the query process
+ **
+ ** In this case we select all content between "<h1>New snippets</h1>"
+ ** and "<p id="rss">" this returns all snippet links, and no other links
+ ** (like header or navigation links)
+ */
+
+ $wsql->isolate_content('<h1>New snippets</h1>', '<p id="rss">');
+
+ /*
+ other examples:
+
+ $wsql->isolate_content('<body>', '</body>');
+ $wsql->isolate_content('<!--content:start-->', '<!--end-->');
+ */
+
+ /* execute a query:
+
+ This query returns all links:
+ */
+ if (!$wsql->query('SELECT * FROM a')){
+ print "Query error: " . $wsql->error;
+ exit;
+ }
+
+ // fetch results as array
+ foreach($wsql->fetch_array() as $row){
+
+ print_r($row);
+
+ }
+
+?>
\ No newline at end of file |