PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Oliver Smith   c_mysql   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example
Class: c_mysql
Access MySQL tables returning arrays and XML
Author: By
Last change:
Date: 20 years ago
Size: 894 bytes
 

Contents

Class file image Download
<?php
   
include_once("c_mysql.php");
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
    $host
= "localhost";
   
$user = "root";
   
$pass = "";
   
$db = "mysql";
   
$table = "db";
   
//create a c_mysql object
   
$mysql_obj = new c_mysql($host, $user, $pass, $db);
//get data from the database
   
$mysql_data = $mysql_obj->c_mysql_SELECT($table, "*");
//print the data
   
echo "data as an array:<br>\n";
    echo
"<pre>\n";
   
print_r($mysql_data);
    echo
"</pre>\n<br><br>";
   
//change the return format
   
$mysql_obj->c_mysql_set_format("xml");
//get data from the database
   
$mysql_data = $mysql_obj->c_mysql_SELECT($table, "*");
//print the data
   
echo "data as an xml (view source):<br>\n";
    echo
"<pre>\n";
   
print_r($mysql_data);
    echo
"</pre>\n<br><br>";
?>
</body>
</html>