PHP and MySql HELP
PHP
is
available with all accounts. It is another programming language similar to "C".
It is beyond this simple page to teach this programming language and it is
highly recommended that reference* manuals be used.
MySql
is
available on some accounts and is a powerful database program and when used
together with PHP it can provide amazing web page content. Again, it is not the
intention of this page to teach MySql programming.
phpMyAdmin
is provided to manipulate your MySql database from your browser. This is
a password protected page and can be accessed from
http://youdomain.com/mysql
Example of a DHTML page as would be used on a
catalog.
- Create a
table in your database called "Catalog":
Using
phpmyadmin, Enter
catalog as the name and 3 fields
- Set parameters of the items in the table:
Field = ID, TYPE = INT, Length = 11, not null, Extra=Auto_Increment,
check Primary
Field = Name, Type = VARCHAR, Length = 32
Field = Price, Type = FLOAT, Length = 6,2
- Populate the table by putting the following into the query block.
INSERT INTO CATALOG (Name, Price) VALUES ('Toothbrush', 1.79);
- Press the "Go" button to add the data to the table
- Using the format as above make
a few more entries into the table.
Now lets create a web page to display a simple
table with the complete catalog.
You should be able to cut and paste this into your
web page. Make sure you use a "php" extension for the page. (maybe test.php) Also make sure you change the "database",
"user" and "password"
in the HTML code below.
<HTML>
<HEAD>
<TITLE> Test PHP and MySQL </TITLE>
<BODY>
<?
// connect to server
$mysql_link = mysql_connect("localhost", "user", "passwordr");
// Select the Database
mysql_select_db("database_db", $mysql_link);
// Get everything from the catalog table
$query = "SELECT * FROM catalog ";
$mysql_result = mysql_query($query, $mysql_link);
//Statr Table
print ("<TABLE BORDER=\"0\">");
//Create header row
print ("<TR>\n");
print ("<TD BGCOLOR=\"#CCCCCC\"><B>Item</B><TD>\n");
print ("<TD BGCOLOR=\"#CCCCCC\"><B>Price</B><TD>\n");
print ("</TR>\n");
//Get Each Row
While ($row = mysql_fetch_row($mysql_result))
{
//Get Columns
$item_ID = $row[0];
$item_Name = $row[1];
$item_Price = $row[2];
print ("<TR>\n");
print ("<TD>$item_Name</TD>\n");
print ("<TD ALIGN=\"right\">");
"php.php" 52L, 898C written
frogleg : vi php.php
// Get everything from the catalog table
$query = "SELECT * FROM catalog ";
$mysql_result = mysql_query($query, $mysql_link);
//Start Table
print ("<TABLE BORDER=\"1\">");
//Create header row
print ("<TR>\n");
print ("<TD BGCOLOR=\"#CCCCCC\"><B>Item</B></TD>\n");
print ("<TD BGCOLOR=\"#CCCCCC\"><B>Price</B></TD>\n");
print ("</TR>\n");
//Get Each Row
While ($row = mysql_fetch_row($mysql_result))
{
//Get Columns
$item_ID = $row[0];
$item_Name = $row[1];
$item_Price = $row[2];
print ("<TR>\n");
print ("<TD>$item_Name</TD>\n");
print ("<TD ALIGN=\"right\">");
print ("\$$item_Price</TD>\n");
Print ("</TR>\n");
}
?>
</TABLE>
</BODY>
</HTML>
Reference books:
Core PHP Programming, Leon Atkinson, ISBN 0-13-020787-x
PHP Programming, J.Castagnetto, H.Rawat, S. Schuman, C. Scollo, D. Veliath, ISBN
1-861002-96-3
MYSql, Paul DuBois, ISBN 0-7357-0921-1
Home
Web Mail Web
Packages Domain Names
Secure Server
Control Panel
CGI
Programming
Host Maintenance
Web Site Help Adult Site Policy
General Policy
Contact Us
Copyright © 1995 - 2025 OL
Communications, Inc.
Simply The Best |