Jump to content

[SOLVED] ORDER BY fails :(


wmguk

Recommended Posts

Hey,

 

$orderby is set using a form.

$orderby = (empty($_POST['orderby'])) ? "name ASC" : $_POST['orderby'] ;

 

then the actual form

<form action="../show_tile.php" method="POST" name="search">
            <input type="image" name="orderby" value="name ASC" src="../images/asc.gif" />
            <input type="hidden" name="colour" value="<? echo $colour ; ?>" />
          </form>
<form action="../show_tile.php" method="POST" name="search">
            <input type="image" name="orderby" value="name DESC" src="../images/desc.gif" />
            <input type="hidden" name="colour" value="<? echo $colour ; ?>" />
          </form>

 

I am using this query:

$result = mysql_query("SELECT * FROM products WHERE colour = '$colour' ORDER BY $orderby");

 

I checked it using a GET and its not passing the variable orderby -

<input type="image" name="orderby" value="name ASC" src="../images/asc.gif" />

 

any thoughts what Ive missed?

Link to comment
https://forums.phpfreaks.com/topic/111466-solved-order-by-fails/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.