PHP Classes

File: examples.php

Recommend this page to a friend!
  Classes of Ciprian Voicu   MySQL Utils   examples.php   Download  
File: examples.php
Role: Example script
Content type: text/plain
Description: some examples
Class: MySQL Utils
Access MySQL and output results as HTML or XML
Author: By
Last change:
Date: 18 years ago
Size: 1,215 bytes
 

Contents

Class file image Download
<?

// BE SURE TO CHANGE THE VALUES FROM THE db_connect.php WITH YOU DATABASE ACCOUNT

include "db_connect.php";
require_once(
"class.mysql.php");
$db = new MYSQL($host, $username, $password, $database);

/* MYSQL ACCESS

$db->FetchMode(2); // this will set the fetch mode to MYSQL_BOTH
$db->Query("SELECT * FROM `table`"); // query

$db->Insert("INSERT INTO `table` (`id`, `description`, `username`) VALUES ('','??','??');", array('my " description ', 'another one')); // this will insert tha data from the array escaped before with mysql_real_escape_string

$next_id=$db->LastId()+1; // retrive last id inserted and concatenate it

*/

/* TABLE
$db->AddClass('table', 'classname'); // add a class to the table element
$db->AddThStyle('background', '#cccccc'); // add a style to the th element
$db->ThLabels('', '', 'my name'); // change the third th label

$db->Table("SELECT * FROM `table`"); // outputs te table
*/

/*
$db->XML("SELECT * FROM `sets`"); // get the data from the database and compose an xml object
$db->XMLGet(); // outputs the xml in browser
$db->XMLGet(2); // promt for download the xml

$db->XMLSave('folder/data.xml'); // save the file to the server

*/
?>