Re: Table sorting with PHP/MySQL

From: Date: Tue, 30 May 2000 11:04:57 +0000
Subject: Re: Table sorting with PHP/MySQL
Groups: php.general 
Request: Send a blank email to php-general+get-591@lists.php.net to get a copy of this message
> How should I do this? How about something along the lines of... > $result = MYSQL_QUERY("SELECT * FROM keyword ORDER BY id"); > > > // Header stuff goes here. > > // Get results & output to browser.. Note that Id is assumed to be >=0 for this > to work.. > $last_id = -1; > while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { > if ($last_id != $row["id"]) { > if ($last_id >= 0) > echo "</td></tr>\n"; > echo "<tr><td valign='top' > align=center>"; > echo $row["id"]; > echo "</td><td valign='top' > align=center>"; > $last_id = $row["id"]; > }; > echo $row["word"] ." &nbsp; "; > }; > if ($last_id >= 0) > echo "</td></tr>\n"; > echo "</table>\n"; > > // End stuff..

« previous php.general (#591) next »