I WAS WONDERING IF SOMEONE COULD POINT ME IN THE DIRECTION OF A SIMPLE SCRIPT THAT I COULD SET UP. I WOULD LIKE TO CREATE A MYSQL FILE AND PRINT OUT THE RECORDS OF CONTACTS IN ALPHABETICAL ORDER ON A PAGE IE A LIST OF LOCATIONS. I HAVE PHP AND MYSQL SPACE BUT NOT VERY MUCH EXPERIENCE IN WEB STUFF. THANKS VERY MUCH
Basically, you need to insert all the data you need with a form or with cpanel if you have virtual hosting. Then you need to use
PHP Code:
<?php
// first we need to connect and be using the database
$link = mysql_connect('localhost', 'yourusename', 'yourpassword')
or die('Could not connect: ' . mysql_error());
mysql_select_db('yourdatabasename') or die('Could not select database');
$sql = 'SELECT * FROM `tablename` ORDER BY `columnname` DESC';
/* creates a variable containing SQL syntax- 'ORDER BY' sorts your results.
You can change the word DESC into ASC if you want to order your results
the other way around */
$result=mysql_query($sql) or die(mysql_error()); /* executes your query with
the function mysqk_query(). If this fails it will tell you why */
echo "<table>" ; //creates a table to put the results in
/* just echoing the $result wont work as this is a resource identifier
for the whole table, rather than anything legible. So use this code
which sets up a loop. Just change the html tags when you feel like it */
while ($row = mysql_fetch_array($result))
{
echo "<tr><td>" ;
print_r($row); # each row is printed inside <tr> and <td> tags
echo "</td></tr>" ;
}
echo "</table>" ; //ends that table
?>
Looks more complecated then it actually is, just play around and you'll get it