php 3 steps

15
Select data From mysql When you need data from your mysql database to show in your web page, you need to select database, table and what's row you want to pull its data first. Syntax // Select all columns from all rows. "SELECT * FROM table_name"; or // Select some column from all rows. "SELECT column_name1 column_name! FROM table_name"; or // Select all coulumns from one row. "SELECT * FROM table_name #ERE column_name$% &alue 'n column %"; Overview In this tutorial, we'll create only 1 file. 1. select.php Steps 1. Create table "test_mysql" in database "test". . Create file select.php. !. test it If you don't want looping rows in mysql, replace w('le) rows$m+s,l_fetc(_arra+) result-- ........ 0 ( 2 m+s,l_close)-; 03 replace with this rows$m+s,l_fetc(_arra+) result-; ......... 0 ( m+s,l_close)-; 03 STEP1: Create table "test_mysql" In this step, you ha#e to create a table and insert data for testing our code.

Upload: smilebaddy

Post on 04-Oct-2015

221 views

Category:

Documents


0 download

DESCRIPTION

about Php

TRANSCRIPT

Select data From mysqlWhen you need data from your mysql database to show in your web page, you need to select database, table and what's row you want to pull its data first.Syntax// Select all columns from all rows."SELECT * FROM table_name";or// Select some column from all rows."SELECT column_name1, column_name2 FROM table_name";or// Select all coulumns from one row."SELECT * FROM table_name WHERE column_name=' value in column '";OverviewIn this tutorial, we'll create only 1 file.1. select.php

Steps1. Create table "test_mysql" in database "test".2. Create file select.php.3. test it!If you don't want looping rows in mysql, replace

while($rows=mysql_fetch_array($result)){........

replace with this$rows=mysql_fetch_array($result);.........

STEP1: Create table "test_mysql"In this step, you have to create a table and insert data for testing our code.

CREATE TABLE `test_mysql` (`id` int(4) NOT NULL auto_increment,`name` varchar(65) NOT NULL default '',`lastname` varchar(65) NOT NULL default '',`email` varchar(65) NOT NULL default '',PRIMARY KEY (`id`)) TYPE=MyISAM AUTO_INCREMENT=7 ;---- Dumping data for table `test_mysql`--INSERT INTO `test_mysql` VALUES (1, 'Billly', 'Blueton', '[email protected]');INSERT INTO `test_mysql` VALUES (2, 'Jame', 'Campbell', '[email protected]');INSERT INTO `test_mysql` VALUES (3, 'Mark', 'Jackson', '[email protected]');INSERT INTO `test_mysql` VALUES (4, 'Linda', 'Travor', '[email protected]');INSERT INTO `test_mysql` VALUES (5, 'Joey', 'Ford', '[email protected]');INSERT INTO `test_mysql` VALUES (6, 'Sidney', 'Gibson', '[email protected]');

STEP2: Create file - Select.php

STEP3: Run the Code

Insert data into mysqlThis tutorial will show you how to insert data into mysql database.Syntax"INSERT INTO table_name(column_name1, column_name2)VALUES('value1, 'value2')" ;OverviewIn this tutorial, create 2 files1. insert.php2. insert_ac.php

Steps1. Create table "test_mysql" in database "test".2. Create file insert.php.3. Create file insert_ac.php.

If you don't know how to create database and table click here to learnSTEP1: Create table "test_mysql"CREATE TABLE `test_mysql` (`id` int(4) NOT NULL auto_increment,`name` varchar(65) NOT NULL default '',`lastname` varchar(65) NOT NULL default '',`email` varchar(65) NOT NULL default '',PRIMARY KEY (`id`)) TYPE=MyISAM AUTO_INCREMENT=0 ;STEP2: Create file insert.phpView In Browser

############### Code

Insert Data Into mySQL Database

Name:

Lastname:

Email:

STEP3: Create file insert_ac.phpDiagram

############### Code