Reverse SQL query results

dragon2309

P.I Dragon
Hey there, got a new client and she wants the relts of a standard SQL query to now be reversed when they are printed on a PHP page, at the moment they are being sorted by their Stockcodes which are in numerical order of course, i need them to go abckwards, from 10 to 1 instead of 1 to 10.......

Anyone any ideas, after 1 hour of fiddling in MySQL ControlCenter and PHPMyAdmin i really cant find nor think of anything to do...... anyone.
 
well, heres my current php block that carries out the SQL transaction, could you explain a bit more how i would implement a reverse for loop....

PHP:
<?php
     include "dbinfo.php";

     // Connect to MySQL DBMS
     if (!($connection = @ mysql_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD)))
       showerror();

     // Use the jewellery database
     if (!mysql_select_db(DB_DATABASENAME, $connection))
       showerror();

     // Create SQL statement
     $query = "SELECT * FROM earring where StockCount > 0";

     // Execute SQL statement
     if (!($result = @ mysql_query ($query, $connection)))
       showerror();

	 // Display results
	while ($row = @ mysql_fetch_array($result))
       echo "<tr><td>{$row["StockCode"]}</td>
       <td>{$row["Description"]}</td>
       <td>{$row["Price"]}</td>
       <td><p><a href='{$row["IMGURL"]}'><img src='{$row["IMG"]}'></img></p></td>
       <td><center><a href='{$row["URL"]}'>$row[URL]</a></center></td></tr>";

   ?>

thanks, dragon2309
 
Last edited:
i tried that, seeing as the stock codes are in numerical order, perhaps sort them backwards on a database level, but i tried and it didnt seem to do anything, if anyone knows how to do this in either "PHP My Admin" or MySQL Control Center that would be great......
 
Back
Top