Your Ad Here

 Navigation
Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Blog
Books
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links




 Sponsors
 Links
finance products
gambling sites
software directory
 Downloads
 Misc
Webmaster Resources
Only PHP
ScriptSearch.com
Scripts.com - Get the best scripts NOW!
AndreaPHP Programming

Valid XHTML 1.0 Transitional


Valid CSS!


Displaying our database results


Displaying our database results

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";
}
?>

That is all there is to it , to see all of this in action we have an example page , testing our db

Page 1 : adding to our database

Page 3 : delete from our database




Books
 Sponsors
 Random Code
Random number examples(randomizing)
PHP and cURL example(internet)
Email verify function(internet)
 Random Article
  Network
Programming resources
Tutorials directory
Clickbank mall
sell software
Free auctions, low cost stores
UK products
US products
Gambling directory
Sexy free wallpapers
Hosting resources
ASP site
DVD site
Domain names
Dating site
Software directory
Maxi directory
bigarticle : free articles




beginners PHP Copyright © 2004 onwards by beginnersPHP.