ok i have one text box named q and one selection box called sortOrder as follows:
<body></body>
<form name="form" action="<? $PHP_SELF; ?>" method="get">
<input type="text" name="q" />
<select name ="sortOrder">
<option value="ASC">ASC</option>
<option value="DESC" >DESC</option>
</SELECT>
<input type="submit" name="Submit" value="Search" />
</form>
then i have this code for pagination
<?php
// Get the search variable from URL
$var = @$GET['q'] ;
$var2 = @$GET['sortOrder'] ;
$trimmed = trim($var); //trim whitespace from the stored variable
after few lines i have:
$query = "select * from products where id like \"%$trimmed%\" order by '$sortOrder'"; 😕
$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);
** In the $query, $trimmed get a value but not $sortOrder
If I get rid of my single quotes(because in actual query there are no quotes for Order by clause),
I get an error like the following:
Supplied argument is not a valid MySQL result resource
this is how $query looks like when I echo it:
select * from products where id like "%whatever%" order by 'DESC' limit 0,10
(whatever was the text i typed in the $q textbox)
Does anybody know how I can get $sortOrder in the $query so I can sort by ASC or DESC?