<?php
// test.php
require_once "DB.class.php";
header("content-type: text/html");
print "<html><head><title>HAHA</title></head><body>";
print "<h1>HELLO WORLD DB VERSION</h1><br>\n\n";
$db = new DB("login", "pass", "dbname");
// table: test
// fields: id, title, price
$db->query("SELECT * FROM test");
print "<table bgcolor=\"#FFFFCC\" border=1><tr><th>id</th><th>title</th><th>price</th></tr>\n";
while( $db->fetchRow() )
{
print "<tr><td>" . $db->record["id"] . "</td><td>" . $db->record["title"] .
"</td><td>" . $db->record["price"] . "</td></tr>\n";
}
print "</table>\n\n";
print "<p>TESTING moveFirst()</p>\n";
if( $db->moveFirst() )
{
print "FIRST REC: [" . $db->record["id"] . " || " . $db->record["title"] .
" || " . $db->record["price"] . "]<br><br>\n";
}
print "<p>TESTING moveNext()</p>\n";
if( $db->moveNext() )
{
print "NEXT REC: [" . $db->record["id"] . " || " . $db->record["title"] .
" || " . $db->record["price"] . "]<br><br>\n";
}
print "<p>TESTING moveLast()</p>\n";
if( $db->moveLast() )
{
print "LAST REC: [" . $db->record["id"] . " || " . $db->record["title"] .
" || " . $db->record["price"] . "]<br><br>\n";
}
print "<p>TESTING movePrev()</p>\n";
if( $db->movePrev() )
{
print "PREV REC: [" . $db->record["id"] . " || " . $db->record["title"] .
" || " . $db->record["price"] . "]<br><br>\n";
}
// move to the last record and move backwords
$db->moveLast();
print "<p>BACKWORDS:</p>\n";
print "<table bgcolor=\"#FFFFCC\" border=1><tr><th>id</th><th>title</th><th>price</th></tr>\n";
while( $db->movePrev() )
{
print "<tr><td>" . $db->record["id"] . "</td><td>" . $db->record["title"] .
"</td><td>" . $db->record["price"] . "</td></tr>\n";
}
print "</table>\n\n";
// disconnect and show errors
$db->disconnect();
$db->showErrors();
print "</body></html>";
?> |