here is what i have so far....
http://therandomjoe.com/DJM/idea4/address.php
i want to be able to organize by the names at the top "lastName", "email", etc....
the command to do this in the mysql prompt is....
SELECT * FROM phoneList ORDER BY lastName ASC;
how would i call this up from php?
here is the contents of address.php
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<h1>Show Address's</h1>
<?php
//make the database connection
$conn = mysql_connect("localhost", "user", "pass");
mysql_select_db('db_name', $conn);
//create a query
$result = mysql_query('SELECT * FROM phoneList', $conn);
print "<table border =1>\n";
//get field names
print "<tr>\n";
while ($field = mysql_fetch_field($result)){
print " <th>$field->name</th>\n";
} //end while
print "</tr>\n\n";
//get row data as an associative array
while ($row = mysql_fetch_assoc($result)){
print "<tr>\n";
//look at each field
foreach ($row as $col=>$val){
print " <td>$val</td>\n";
} //end foreach
print "</tr>\n\n";
}//end while
print "</table>\n";
?>
</body>
</html>