Free Webmaster Resources .info
PHP Introduction and Tutorials Javascript  Introduction and Tutorials HTML  Introduction and Tutorials ASP  Introduction and Tutorials Free Internet Access Guide and Directory Webspace  Directory Webhosting  Directory Adult Webhosting  Directory PHP Hosting  Directory ASP Hosting  Directory
à Navigation
» Home
» Php Introduction
» Php Tutorials
» Submit Scripts
 
Subscribe for free!

Join our mailing list today and recieve free updates monthly with web hosting specials!
 
 

 

 

Free Webmaster Resources .info | Free PHP Tutorials


Adding data to a Database

In the first part you built the database and the table to store your data and now we are going to show you how to display this information .

The following script does the nitty gritty here , again change the ("hostname" , "username" , "password") to your own settings .

<?php
//make a connection with your details
$connection = mysql_connect("hostname" , "username" , "password")
or die ("Cannot make the connection");
//connect to the sampldb database with our connection details
$db = mysql_selectdb("sampledb" , $connection)
or die ("Cannot connect to the database");
//select all from sample table and store in $sql_query
$sql_query = "SELECT * FROM sample";
//store this in $result
$result = mysql_query($sql_query);
//if an entry exists
if(mysql_num_rows($result))
{
//loop through the fields
while($row = mysql_fetch_row($result))
{
//display the links $row[1] is the link , $row[0]
//is the id value
echo ("<a href=\"$row[1]\">$row[1]</a><br>");
}
}
//if no entry exists print a message
else
{
echo "no values in the database";
}
?>

[more] [1] [2] [3]

Recommended Webhosting Company
Find free web hosting
Looking for free web hosting? Review and compare FindStuff's comprehensive resources. Search now!

 

 
Related Websites
 


Free Email
Your source to free email.

Free Casino Downloads
Contains useful free casino downloads.

Free Software Downloads
A complete collection of free software downloads.

Free
Download free stuff from psike.com your free stuff resource.

Free Teen Online Dating
Meet other singles for free online dating.

Coolfreeweb.com
The Free category at coolfreeweb.com

My Directory Listing
A massive directory listing of websites

Website Collation Project
The website collation project contains a huge directory of websites.


 
Top Webhosts
 
 1. Find free web hosting
 2. free web hosting Web Ho
 3. Web Hosting
 4. Free Web Hosting
 5. Webhosting
 
-
- Give us feedback
 
Last updated
Nov 19, 2008
Free Webmaster Resources .info | A resource must for every web master
Untitled Document - Web Hosting
- PHP Hosting
- Free Internet Access