Display A Database

Dismounted

59.***.***.***
1,958 days ago

Display A Database

Display A Database
*NOTE* This is an add-on to my DB Connection Snippet ("http://www.phpcentral.com/51-connecting-mysql-database.html")!

Place this code where you want the database to be displayed.

PHP code:

<?
mysql_pconnect($db_host, $db_user, $db_pass);
mysql_select_db($db_name);

$result = mysql_query("SELECT * FROM $db_table");

while($r = mysql_fetch_array($result))
{
$data_name = $r['field_name'];
}

echo ("" . $data_name . "");
?>

Pretty much self-explanatory.

penguinmama

12.***.***.***
1,957 days ago
So this just displays EVERYTHING in the database.

If you want to display just parts, do a specific select.

PHP code:


$result = mysql_query("SELECT column1, column2, column3 FROM $db_table");



:)

Dismounted

59.***.***.***
1,953 days ago
Yes, just change the query to display different things.

Bradd

203.***.***.***
1,931 days ago

penguinmama;158:

So this just displays EVERYTHING in the database.

If you want to display just parts, do a specific select.

PHP code:


$result = mysql_query("SELECT column1, column2, column3 FROM $db_table");



:)


Yes you have to have some good knowlege of Sql also if you need to play with all around and that was my first thing which i learn