WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Two Simple Classes used for extremely easy interaction with MySQL
Categories : PHP, PHP Classes, Databases, MySQL Update Picture
Rahul Puranik
Date : Apr 12th 2005
Grade : 3 of 5 (graded 5 times)
Viewed : 3422
File : 4128.php
Images : No Images for this code example.
Search : More code by Rahul Puranik
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?
/**************************************************************
Following function shows the usage of the two classes provided
with this example. I show here use of Insert,Update,Delete
functions as well as for retrieving results with a select query
in pages. The code in the example won't work directly. You will have
replace your own values. This is just a guideline for using MySQLAdo
and Recordset class. See the file DbInterface.php for more info. It's
attached with the example
***************************************************************/
require_once("DbInterface.php");

$myado=new MySQLAdo($hostname,$username,$password,$dbname); //Class used for data manipulation
$recordset=new Recordset(); //Class used for data retrival

//--------------------------------------------------------------------
//Adding data in the database
$myado->inert_array=array(
                           
"col1_name"    =>$value1,
                           
"col2_name"    =>$value2,
                           
"col2_name"    =>$value3,
                           
"col2_name"    =>$value4,
                           
"col2_name"    =>$value5,
                         );

$myado->AddRecord("tablename");
//--------------------------------------------------------------------
//Updating data in the database
$myado->update_array=array(
                           
"col1_name"    =>$value1,
                           
"col2_name"    =>$value2,
                           
"col2_name"    =>$value3,
                           
"col2_name"    =>$value4,
                           
"col2_name"    =>$value5,
                         );

$myado->UpdateRecord("tablename","WHERE $id=$somevalue");

//--------------------------------------------------------------------
//Deleting data from the database
$myado->DeleteRecord("tablename","id=$somevalue"); //Do not use "WHERE"

//--------------------------------------------------------------------
//Getting data from the database
$recordset->GetRecords("SELECT * FROM tablename"); //Use recordset class
$total_records=$recordset->no_of_records;
$i=0;
while(
$i<$total_records)
{
   
$current_record=$recordset->SeekRow($i);
    print
"<tr>";
    print
"<td>".$current_record->col1; //col1 is the field specified in query
   
print "<td>".$current_record->col2;
    print
"<td>".$current_record->col3;
    print
"</tr>";
}

//For pagination use following. You can get all pages in pages array
$recordset->GetRecords("SELECT * FROM tablename",10); //10 records per page
$total_pages=$recordset->no_of_pages;
$page1=$recordset->pages[0];
$page2=$recordset->pages[1];

//$page 1 now contains the array of first 10 rows in the result set.
//$page2 now contains the array of next 10 rows in our result set.
//When you want to print contents of this page do like following

while($i<count($page1))
{
    print
"<tr>";
    print
"<td>".$page1[$i]->col1_name;."</td>";
    print
"<td>".$page1[$i]->col2_name;."</td>";
    print
"<td>".$page1[$i]->col2_name;."</td>";
}
//etc. etc......
?>



usercounter class
Categories : PHP, PHP Classes, Databases, MySQL, Environment Variables
MySQL Handler
Categories : PHP, Databases, MySQL, Classes and Objects, PHP Classes
PostGreSQL and MySQL 2 in 1 db Manager
Categories : PHP, PHP Classes, Databases, PostgreSQL, MySQL
MySQL Class to ease Database connectivity
Categories : MySQL, PHP Classes, Databases, PHP
Simple Mini Poll class library (SimPoll)
Categories : PHP, PHP Classes, Databases, MySQL, Complete Programs
Online Automatic Class Generator for MySQL Tables
Categories : PHP, PHP Classes, Classes and Objects, Databases, MySQL
Specify your connection settings and create a link to a MySQL database.
Categories : PHP, PHP Classes, Databases, MySQL, Beginner Guides
Simple database class
Categories : PHP, PHP Classes, MySQL, Databases
Simple usersOnline class - keep track of how many users are online on your site
Categories : PHP, PHP Classes, Databases, MySQL
Setting up InnoDB on MySQL and using Transactions Begin, Commit, Rollback in PHP.
Categories : PHP Classes, Databases, PHP, MySQL, InnoDB
Ajax PHP Tree (Left and Right) with MySQL
Categories : PHP, Databases, MySQL, AJAX, PHP Classes
YellowPages Content Grabber (PHP5 +)
Categories : PHP, PHP Classes, Regexps, Databases, MySQL
Convert SQL from oracle,mysql,mssql,sqlite and odbc to SQL compatible
Categories : PHP, PHP Classes, Databases, MySQL, MS SQL Server
MySQL Connection/Query Class
Categories : Databases, MySQL, PHP, PHP Classes
Create and restore backup of MySQL databases
Categories : MySQL, Databases, PHP, PHP Classes, Complete Programs