Login   Register  
PHP Classes
elePHPant
Icontem

File: example_using_move*

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Amir Khawaja  >  DB  >  example_using_move*  >  Download  
File: example_using_move*
Role: ???
Content type: text/plain
Description: Example showing how to use the new movePrev(), moveNext(), moveLast, moveFirst() functions.
Class: DB
MySQL database management class.
Author: By
Last change:
Date: 2001-09-07 11:26
Size: 1,950 bytes
 

Contents

Class file image Download
<?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>";
?>