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.

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

$db = "MYDB";
$server = "66.102.135.151";
$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";
}

mysql_close($dbc);
print "</pre>\n";
?>

 

WEB DESIGN INDIA
42 B Malviya Nagar , New Delhi-110017

Skype: manmeetsi
Email: support.webdesignindia@gmail.com
Tel: 91-011-40502005, 9810067295

 















 


© 2008-2009 dotnet4all.com