Custom Search

News World

Oct 24, 2008

PHP Script : Section 06 : How to connect to table in database MySQL with PHP Script

PHP Script : Section 06 : How to connect to table in database MySQL with PHP Script

Step 1. Create database file in MySQL with name : phplesson

Step 2. Create simple table on your MySQL with name : tbl-category-01


Field :
idc >> id category
prdcatecory >> product category
Input your data on your table
idp; prdcategory
1; mouse
2; keyboard
3; hdd
4; usb
5; wap
6; switch
7; router
8; modem
9; power supply
10; monitor
12; memory
13; printer
14; other


Step 3. Create config.inc file (like the sample on page : PHP Script : Section 05 : How to Connect Database MySQL with PHP Script)


Step 4. Create file product-category-list.php
Content:
include 'config/config.inc.php';
$tblprdcat_sql=mysql_query("SELECT * FROM tbl-category-01 ORDER BY idc ASC"); // connect to tbl-category-01
$r_tblprdcat_sql = mysql_num_rows($tblprdcat_sql)); // totaly record/ item table
for($ic=1;$ic<=$r_tblprdcat_sql;$ic++){
$dt_tblprdcat_sql = mysql_fetch_array($tblprdcat_sql); // contents table
echo "record : ".$ic." is : ".$dt_tblprdcat_sql[prdcategory]."/n";//print record
}
?>

Step 5. Run product-category-list.php file

more : web.solusi@gmail.com

No comments:

IT Conversations

Moneycontrol Latest News

Latest new pages on Computer Hope

Latest from Infoworld

Door Lock

Door Lock Import Top Door Lock from China Contact Quality Manufacturers Now