Website Design United States, Website Design California, Website Designing United States, Website Designing California

List MySQL Table Contents via QueryString - PHP

Lists the contents of a MySQL table.

Change $db, $server, and $acct to the appropriate values for connecting to your mysql database.

// Example CGI script to list out the contents of a table in a database.
// Usage: dblist.php?table=TABLE&pw=password

$db = "MYDB";
$server = "";
$acct = "blcss";
$password = $HTTP_GET_VARS['pw'];
$table = $HTTP_GET_VARS['table'];

print "<pre>\n";
print "Here we go... $db:$server\n";
$dbc = mysql_connect($server, $acct, $password);
if (!$dbc) { die("Can't connect to $server"); }
print "Connected, opening database $db\n";
mysql_select_db($db) or die("Can't select $db");
print "Connected, selecting from $table\n";

$sth= mysql_query("select * from $table");

while ($data= mysql_fetch_row($sth)) {
print "Row: ";
foreach ($data as $val) {
print "$val\t";
print "\n";

print "</pre>\n";


42 B Malviya Nagar , New Delhi-110017

Skype: manmeetsi
Tel: 91-011-40502005, 9810067295



© 2008-2009