Viewing a Database

O

old.Pac

Guest
Copy and past this code to view a database:



<?php

// Set the variables for the database access:

$Host = "freesql.org";

$User = "Username";

$Password = "Password";

$DBName= "DBName";

$TableName = "TableName";


// Connects to the database

$Link = mysql_connect ($Host, $User, $Password);


$Query = "select * from $TableName";

$Result = mysql_db_query ($DBName, $Query, $Link);


// Create a HTML Table on your page
// You can add as many files as you like.

print ("<table border=0 cellpadding=3 cellspacing=1 width=\"75%\" align=center>\n");

print ("<tr align=center valign=top>\n");

print ("<td align=center valign=top>Name</td>\n");

print ("<td align=center valign=top>Email Address</td>\n");

print ("<td align=center valign=top>Comments</td>\n");

print ("</tr>\n");


// Fetch the results from the database

while ($Row = mysql_fetch_array

($Result)) {

print ("<tr align=center valign=top>\n");

print ("<td align=center valign=top>$Row[FirstName] $Row[LastName]</td>\n");

print ("<td align=center valign=top>$Row[EmailAddress]</td>\n");

print ("<td align=center valign=top>$Row[Comments]</td>\n");

print ("</tr>\n");

}

mysql_close ($Link);

print ("</table>\n");

?>
 
O

old.Zaldbag

Guest
WOW! That's THE BEST example I have seen yet! Now I motivated to learn PHP!
 
O

old.Pac

Guest
Well thats what the forums are for, to share our knowledge. :)

If you want to see a Roster running this script go to my site (In my sig) and click Roster. Its using the exact script above, only with a few modifications.
 
T

Testin da Cable

Guest
hehe you've even made _me_ interested ;)
btw, can we have a perl tech forum pweeeeeezeee :D
 
O

old.^S0LIDUS^

Guest
is there some sort of proceedure for requesting a new forum??
 
T

Testin da Cable

Guest
yeah begging ;)

nah, I believe one may present a reasoned argument for it via irc/mail/the forum and the request will be considered by the powers that be.

-TdC
 

Users who are viewing this thread

Similar threads

T
Replies
6
Views
756
Testin da Cable
T
M
Replies
2
Views
566
Maljonic
M
O
Replies
10
Views
721
Tempy_Incursion
T
O
Replies
3
Views
544
old.Enterprise
O
Top Bottom