Newbie with sorting problem

From: Date: Tue, 06 Jan 2004 12:40:38 +0000
Subject: Newbie with sorting problem
Groups: php.general 
Request: Send a blank email to php-general+get-173840@lists.php.net to get a copy of this message
Hi all, I'm quite a newbie ot php/mysql, so my question might be oversimple (though i tried for hours to understand..) I'm making an addressbook, as a try out, to see how it al works. All is great actually, but only the sorting of the addresses seems complicated for me.. I have a databse called 'addressen', and four fields of this db are called 'id', 'name', 'surname' and 'address' To display the content i use this: <? include( "file_that_connects_with_my_database.php"); $result = mysql_query( "SELECT id, name, surname, address FROM addresses"); if (!$result) { echo( "<p>Error performing query: " . mysql_error() . "</p>"); exit(); } while ( $row = mysql_fetch_array($result) ) { $addressid = $row["id"]; $nametext = $row["name"]; $surnametext = $row["surname"]; $addresstext = $row["address"]; //the table echo( "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td>"); echo( $addressid. "</td><td>"); echo( $nametext. "</td><td>"); echo( $surnametext. "</td><td>"); echo( $addresstext "</td><td>"); echo( "</tr></table>"); } ?> This scripts works, but.. my desire is now to be able to sort the output, wich is generated by the 'while' loop, for instance on 'name', or on 'surname' . sort(), ksort()? I couldn't understand the explanations i found (and so declared myself as newbie :) Can anybody help me with this? I would be delighted... Thanks in advange! Bart Koppe

« previous php.general (#173840) next »