PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of eugene mercado   clsCustomQuery   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example
Class: clsCustomQuery
Execute MySQL queries and retrieve results
Author: By
Last change:
Date: 19 years ago
Size: 1,024 bytes
 

Contents

Class file image Download
<html>

<head>
  <title></title>
</head>

<body>

<?php
   
include_once("clsCustomQuery.php");

   
$dbh = mysql_connect( "localhost", "username", "password" );
    if( !
$dbh )
        print
"Error: Could not connect to localhost: ". mysql_error() ."<br/>";

   
$sql = new clsCustomQuery( "myDBTable", $dbh );

?>
<table>
<?php
   
if( $sql->query("select * from employees") ){
        foreach(
$sql->fetchrows as $row ){ ?>
<tr align="center"> <?php
           
foreach( $sql->fetchfields as $field ){ ?>
<td><?php echo $row[ $field ]?></td> <?php
           
} ?>
</tr> <?php
       
}
    }else{
?>
<tr><td><?php echo sprintf("Error: detail %s on statement: %s", $sql->error, $sql->statement)?></td></tr> <?php
   
} ?>
</table>

</body>

</html>