Php > Databases
Automatically printing the contents of an sql table in MySQL
Automatically printing the contents of an sql table in MySQL $dbhost="host"; $dbuser="username"; $dbpass="password"; $dbname="database name"; $table="table name"; mysql_connect( "$dbhost", "$dbuser", "$dbpass") or die( "Unable to connect to SQL server"); @mysql_select_db( "$dbname") or die( "Unable to select database"); if(!IsSet($sort)) $result = mysql_query( "select * from $table"); else $result = mysql_query( "select * from $table order by $sort"); ?>
while ($field=mysql_fetch_field($result)) { echo "
name\">$field- >name
"; } echo "
"; while($row = mysql_fetch_row($result)) { echo "
"; for($i=0; $i < mysql_num_fields($result); $i++) { echo "
$row[$i]
"; } echo "
\n"; } echo "
"; ?>
Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage