Affiliate Marketing
Forum Search

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 12-04-08
accelerator's Avatar
Online shopping rocks!
 
Join Date: Nov 2004
Location: England
Posts: 1,194
Thanks: 5
Thanked 9 Times in 6 Posts
accelerator is an unknown quantity at this point
  Database operations in php

Hi All

I'm switching a lot of my coding from asp.net to php, so I'm in need of a good tutorial covering the basic database operations (CRUD) for php, especially the edit and delete functionality at the moment.

Any links much appreciated.

Rgds

Accelerator
__________________
WebRef.eu - Web Development Resources for the Online Entrepreneur
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 12-04-08
Registered User
 
Join Date: Feb 2006
Location: Gillingham
Posts: 502
Thanks: 0
Thanked 0 Times in 0 Posts
Donk is an unknown quantity at this point
  Re: Database operations in php

This may be a bit technical but it covers every eventuality:

Mysql.com

For a tutorial go to W3Schools Online Web Tutorials
__________________
They came for my 404 and I said nothing

Last edited by Donk; 12-04-08 at 05:43 PM. Reason: spelling
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-04-08
tbp tbp is offline
Registered User
 
Join Date: Dec 2006
Posts: 1,916
Thanks: 0
Thanked 10 Times in 10 Posts
tbp is an unknown quantity at this point
  Re: Database operations in php

PM me your email address, and I`ll send you a custom database class that I wrote that makes it incredibly simple to work with MySQL in PHP. I use it in every project I do, and it's saved so much time, also makes clean easy to read code.

All you need to do is to include the file on your page:

PHP Code:
require_once("/server/path/to/site/classes/database.php"); 
and then use the following code.

To read in data:

PHP Code:
$sql "SELECT id, username FROM table";
$db = new Database();
$db->dbOpenDatabase();
$results $db->dbResults($sql);
$db->dbCloseDatbase(); 
This returns an array in results containing all the records, to display the data you use:

PHP Code:
foreach($results as $record){
  echo 
$id " - " $username "<br>";

To add a record:

PHP Code:
$sql "INSERT INTO tablename (username) VALUES('tbp')";
$db->dbOpenDatabase();
$db->dbAddRecord($sql);
$db->dbCloseDatabase(); 
To update a record:

PHP Code:
$sql "UPDATE tablename SET username = 'tbp-new' WHERE username='tbp'";
$db->dbOpenDatabase();
$db->dbUpdateRecord($sql);
$db->dbCloseDatabase(); 
And to delete a record:

PHP Code:
$sql "DELETE FROM tablename WHERE username = 'tbp'";
$db->dbOpenDatabase();
$db->dbDeleteRecord($sql);
$db->dbCloseDatabase(); 
All the MySQL connection and associated code to read records etc is handled internally by the class so you don't have to worry about it.

As you can see it makes it incredibly easy, you just need to know the relevant SQL and the class does the rest.

The same goes to anyone else, anyone wants a copy I`m quite happy to give it out, just PM me with your name and email address and i`ll send it over.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 13-04-08
accelerator's Avatar
Online shopping rocks!
 
Join Date: Nov 2004
Location: England
Posts: 1,194
Thanks: 5
Thanked 9 Times in 6 Posts
accelerator is an unknown quantity at this point
  Re: Database operations in php

Thanks, PM sent.
__________________
WebRef.eu - Web Development Resources for the Online Entrepreneur
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 17-04-08
Registered User
 
Join Date: Mar 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
SimonW is an unknown quantity at this point
  Re: Database operations in php

Their is a free plugin for Dreamweaver that does some basic CRUD in PHP with MySQL. We picked it up as part of webassist (webassist.com) but I believe the basic crud stuff is all free software they happened to bundle with their cart product. It isn't lovely - but it is just about tolerable, and is great if you use Dreamweaver for the sites.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Anyone anygood with xml, php, mysql and Affiliate Window AnnonnyMouse The Affiliate Marketing Lounge 1 23-09-04 11:00 AM
Php & Sql Wunderlust1 Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 8 20-08-04 10:22 AM
PHP - No input file specified. - Problem Barry Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 1 02-08-04 10:57 AM
PHP or Browser Timeout? Barry Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 6 28-04-04 01:04 PM
Including a PHP include within a PHP include ?? madstock Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 3 17-12-03 09:00 PM


Affiliate Marketing RSS Feeds - Contact Us - Affiliate Marketing - Archive - Privacy Statement - Top

Content Relevant URLs by vBSEO 3.2.0 RC7