phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


AJAX - MySQL: Creating Database

Tag: AJAX, DOM, XML, XMLHttpRequest, JavaScript, mysql, database   Category: PHP Application
post: 23 Mar 2008 read: 489


AJAX MySQL Step By Step Tutorial - Part 1: To retrieve data from MySQL, what we need just transform array data from MySQL to XML use DOM.

For practice, create a database named "test". You can use phpMyAdmin or use line codes such as:


<?
//the example of making MySQL database
//create.php
$conn = mysql_connect("localhost","root","admin");
if($conn){
	echo("Connection is succeed");
}else{
	echo("Connection is fail");
}
$make = mysql_create_db("test");
if($make){
	echo("Database data_root succeeds in making");
}else{
	echo("Database data_root fails in making");
}
?>

In this practice, we create a table named "books". You can execute this query:


CREATE TABLE `books` (
  `id` int(11) NOT NULL auto_increment,
  `title` varchar(255) NOT NULL,
  `author` varchar(60) NOT NULL,
  PRIMARY KEY  (`id`)
)

Such as:


<?
mysql_connect('localhost','root','admin');
mysql_select_db('test');

$sql = "CREATE TABLE `books` (
  `id` int(11) NOT NULL auto_increment,
  `title` varchar(255) NOT NULL,
  `author` varchar(60) NOT NULL,
  PRIMARY KEY  (`id`)
)";
mysql_query($sql) or die(mysql_error());
?>

How to create use phpMyAdmin, you can read at this post.

Last, enter sample data such as this query:


INSERT INTO `test`.`books` (
`id` ,
`title` ,
`author`
)
VALUES (
NULL , 'PHP Undercover', 'Wiwit Siswoutomo'
), (
NULL , 'PHP Enterprise', 'Wiwit Siswoutomo'
);

Next, we create XML from this data use DOM.



Series this article:
AJAX - MySQL: Creating Database
AJAX - MySQL: Creating XML Data use DOM
AJAX - MySQL: Creating Client Side

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting