I have a query where I'd like to use 'ORDER BY id' to have some order
to the way the query is displayed.  Using ORDER BY works fine so long
as the query form parameters are set for "All" initially, otherwise I
get an error.  Can someone point me in the right direction
on correcting this error?

Thanks very much for any help,

john
----------------------------- w/o ORDER BY below-------------------
<?
$query = 
       "SELECT *
        FROM actions_tbl 
        WHERE 1 = 1 ";
        if($date != "All") $query .= "and date = '".$date."'";
        if($source != "All") $query .= "and source = '".$source."'";
        if($type != "All") $query .= "and type = '".$type."'";
$result = mysql_query($query);

$number = mysql_numrows($result);
----------------------------w/ORDER BY below---------------------
<?
$query = 
       "SELECT *
        FROM actions_tbl 
        WHERE 1 = 1 
        ORDER BY id ";
        if($date != "All") $query .= "and date = '".$date."'";
        if($source != "All") $query .= "and source = '".$source."'";
        if($type != "All") $query .= "and type = '".$type."'";
$result = mysql_query($query);

$number = mysql_numrows($result);

Reply via email to