I know similar code has been posted ahead of me. But I have used this code for many projects, and it has not failed yet. So I will post if for anyone to use. Its pretty simple.
PHP Code:
$server = "[SERVER]"; //url for the mysql server
$DBuser = "[USERNAME]"; //database username
$DBpass = "[PASSWORD]"; //database password
$DB = "[DATABASE NAME]"; //actual database name
$table = "[TABLE NAME]"; //database table name
mysql_connect($server,$DBuser,$DBpass); //connect to server
mysql_select_db($DB); //select database
$info = mysql_query("SELECT * FROM ".$table."");
//change the row names to fit your needs/wants
echo '<table>';
while ($qry = mysql_fetch_array($info)) {
echo '<tr><td>'.$qry[Lname].'</td><td>'.$qry[Fname].'</td></tr>;
}
echo '</table>';
It is important to have the periods "." after a ' or " and right before a ' or "
ie.
Code:
echo '<tr><td>'.$qry[Lname].'</td><td>'.$qry[Fname].'</td></tr>;
Bookmarks