Your Ad Here

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




 Sponsors
 Links
dvd information
finance products
golfing products
 Downloads
dzphp editor
EasyPHP
mysql_phpgenerator
php-studio-trial
phpdesigner_7_2_5
phpMyAdmin-3.4.3.2
/phptriad2-2-1
phpxedit_321
rapidphp 2011
WampServer2.1d-x64
WampServer2.1e-x32
xampp-win32-1.7.4-VC6-installer
xampplite-win32-1.7.3
 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
bbc science/nature with PEAR packages(xml)
Using the array_rand function(beginner)
Count words in a sentence(string)
 Random Article
  Network
Programming resources
Tutorials directory
Hosting resources
ASP site
Domain names
Progged
Maxi directory
bigarticle : free articles
A Code
Code N Tutorials
Get PHP
Programmers help




beginners PHP Copyright © 2004 onwards by beginnersPHP.