Main Menu

HOME

.Net
ASP
Assembly
C
C++
Delphi
HTML
Java
JavaScript
MySQL
PC interface
Powershell
Perl
PHP
VBScript
Visual Basic
XML

US Job listings




   Misc

   Amazon

   Links

    


Display fields alphabetically

 

OK the next challenge you need to display your links alphabetically, in this example we list them by the name field in the database. We use the ASC keyword to order them from a to z. If you wished to list them from z to a you could use the DESC keyword instead.

<?php
//connect to server with username and password
$connection = mysql_connect ("localhost","username", "password") or die ("Cannot make the connection");
//connect to database
$db = mysql_select_db ("test",$connection) or die ("Cannot connect to database");
//our SQL query
$sql_query = "SELECT * FROM test ORDER BY name ASC";
//store the SQL query in the result variable
$result = mysql_query($sql_query);
if(mysql_num_rows($result))
{
//output as long as there are still available fields
while($row = mysql_fetch_row($result))
{
echo ("<a href=\"$row[2]\">$row[3]</a>");
echo (": $row[4]<br>");
}
}
//if no fields exist
else
{
echo "no values in the database";
}

?>

 


 

 

follow this link to take a look


 




   Sponsors
 

   Software
500 Java Tips E-book
PHP editor
PERL editor
Beginning Java
Beginning Visual Basic
Learn VB.net
Learn VB 6
VB and databases
ASP image library
C++ builder programming
C++ fundamentals

   Source Code
displays information about your computer(Powershell)
Delete a file(ASP)
displays some disk drive parameter in an excel spreadsheet(VBScript)
display local network information(VBScript)
dial a number(VB)
Referring page(Javascript)
octal to decimal conversion(PHP)
read contents of a directory(PHP)

    




Copyright © 2004 by programmershelp.co.uk