PHP Classes

File: example

Recommend this page to a friend!
  Packages of Hansen Wong   MySQL connection and query   example   Download  
File: example
Role: Example script
Content type: text/plain
Description: example
Class: MySQL connection and query
Connect and query MySQL databases
Author: By
Last change: update comment
Date: 14 years ago
Size: 458 bytes
 

 

Contents

Class file image Download
<?php
/** http://chatfren.com/ **/
/** Chatfren Live: http://chatfren.com/chat.php?u=huang_hanzen **/
/** Example **/

require 'class_sql.php';
$db = array(
    'host'        => 'localhost',
    'username'    => 'root',
    'password'    => '',
    'database'    => 'test'
);

$db = new MySQL($db);
$sql = 'SELECT * FROM `table` LIMIT 20';

$db->query($sql);
while($data = $db->fetch()){
    /** loop data here **/
}
echo 'Total Rows: '.$db->rows();
$db->close();
?>