|
Posted by jcage on 11/08/07 14:09
On Nov 8, 5:25 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> jc...@lycos.com wrote:
> > On Nov 2, 8:52 pm, Chris Gorospe <ch...@ekast.com> wrote:
>
> >> Just use the 'ORDER BY name DESC' with your 'select *', and that should
> >> get you want you're looking for.
> > ----------------------------------------
>
> > $query = "SELECT DISTINCT names
> > FROM $table
> > Order by names";
> > $result = mysql_query($query);
>
> > So.... :-)
>
> > In the above code, 'Order by' works very well when not used in
> > conjunction with other queryable items but how about when used in a
> > query where other possible choices are included? How do I use 'Order
> > by' in the query below where it will only act on 'names' when "All" is
> > selected and otherwise, not really be active during the query as in
> > the code below? Any thoughts? TIA
>
> > $query = "SELECT *
> > FROM $table
> > WHERE 1 = 1 ";
> > if($year != "All") $query .= "and year = '".$year."'";
> > if($status != "All") $query .= "and status = '".$status."'";
> > if($names != "All") $query .= "and names = '".$names."'";
> > $result = mysql_query($query);
>
> This isn't a PHP question.
>
> Try comp.database.mysql when asking mysql questions. That's where the
> SQL experts hang out.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================
will do. thanks for the tip.
[Back to original message]
|