<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>RC4PHP TEST</title>
</head>
<body>
<?PHP
require('rc4php_autoload.php');
try
{
/*create new MySQL object - do not forget to replace parameters databaseName, serverNameOrIP, userName and password with your actual values*/
$sql=new RC4PHP_DB_MySQL('databaseName','serverNameOrIP','userName','password');
/*
or if you prefer you can use following method
$sql=RC4PHP_DB_OBJECT::create(RC4PHP_DB_OBJECT::DB_MYSQL,'databaseName','serverNameOrIP','userName','password');
*/
/*example for retriving databases*/
print '<h3>DATABASES</h3>';
$dbs=$sql->databases;
foreach($dbs as $db)
print $db.'<br>';
/*example for retriving tables*/
print '<h3>TABLES</h3>';
$tbs=$sql->tables;
foreach($tbs as $tb)
print $tb.'<br>';
/*create sql query - do not forget to replace "select query" with your select command*/
$rs=$sql->query("select query");
/* if u need to allow users to select pageSize,
the maxPageSize property is useful by
not allowing to set a pageSize greater then maxPageSize
*/
$rs->maxPageSize=15;
/* set size of page */
$rs->pageSize=isset($_GET['pageSize'])?($_GET['pageSize']):(3);
/* set current page */
$rs->page=isset($_GET['page'])?($_GET['page']):(1);
if(isset($_REQUEST['prev']))
$rs->page--;
if(isset($_REQUEST['next']))
$rs->page++;
?><h4>
<?PHP
print 'MIDAS date='.$sql->DATE2MIDAS().'<br>SQL server -> '.$sql->version.'<hr>Page '.$rs->page.'/'.$rs->pages.'<br>Page size '.$rs->pageSize.'<br>Rows '.$rs->rows;
?>
</h4>
<hr>
<?PHP
/* display data from query */
while($row=$rs->fetchRow())
print '$row[0]='.$row[0].'<br>';
?>
<form method="get" target="_self">
<div style="position:absolute; right:0px; top:0px">
Records per page: <input type="text" name="pageSize" value="<?PHP print $rs->pageSize; ?>" onchange="self.document.forms[0].submit();">
</div>
<hr>
<!-- dispays page select menu -->
<div align="center">
<h4>
<?PHP if($rs->page>1)
{
?>
<input type="submit" name="prev" value="<<">
<?PHP
}
?>
<u>P</u>age:
<?PHP
$rs->printPageSelect('page',' accesskey="p" style=" text-decoration:none; color:#AAAAAA;" onchange="self.document.forms[0].submit();"');
?>/<?PHP print $rs->pages; ?>
<?PHP
if($rs->page<$rs->pages)
{
?>
<input type="submit" name="next" value=">>">
<?PHP
}
?>
</h4>
</div>
</form>
<?PHP
/* the following 4 lines are not really necessary: freeResult() and disconect() methods are called automatically at the end of the script */
$rs->freeResult();
$sql->disconnect();
unset($rs);
unset($sql);
}
catch(DBSQLException $e)
{
?><hr style="color:#FF33CC; background-color:#FF33CC"><?PHP
print 'MESSAGE = "'.$e->getMessage().'"<br>CODE = <b>'.$e->getCode().'</b><br><b>BACKTRACE</b>=';
}
?>
</body>
</html>