Login   Register  
PHP Classes
elePHPant
Icontem

File: class_mysql_sample.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Mark Quah  >  MARK_MYSQL  >  class_mysql_sample.php  >  Download  
File: class_mysql_sample.php
Role: Example script
Content type: text/plain
Description: Sample script
Class: MARK_MYSQL
MySQL interface
Author: By
Last change: bug fix.
Date: 2002-11-20 09:57
Size: 1,218 bytes
 

Contents

Class file image Download
<?php

    
include("class_mysql.php");

    
//===== set up sql connection
    
$mysql=new MYSQL("server""mysql userid""mysql passwd""mysql DB");

    
//==== Extract Result
    
$status $mysql->RunDB("select * from user;");
    if (
$status != "OK")
    {   echo 
"<HR>DB Error: $status.<HR>";
        die;
    }
    for (
$i 0$i $mysql->no_rows$i ++)
    {
        echo 
"Record No: " . ($i 1) ."<HR>";
        for (
$j 0$j $mysql->no_fields$j ++)
        {
            
$field_name $mysql->field[$j];
            echo 
"Field: ".$field_name."  ----- Value: ".
                
$mysql->row[$i][$field_name]."<BR>";
        }
    }

    
//==== Use the built-in ShowHTML format
    
$status $mysql->RunDB("select * from user;");
    if (
$status != "OK")
    {   echo 
"<HR>DB Error: $status.<HR>";
        die;
    }
    
$mysql->ShowHTML("","","CENTER");

    
//==== Run some query not expecting results
    
$stmt = ("FILL IN YOUR STAEMENT eg. INSERT INTO");
    
$status $myql->RunDB($stmt0);
    if (
$status != "OK")
    {   echo 
"<HR>DB Fail: $status.<HR>";
        die;
    }
    else
    {   echo 
"<HR>Success: $status.<HR>";
        die;
    }

?>