List:General Discussion« Previous MessageNext Message »
From:Pooly Date:September 18 2005 10:38am
Subject:Re: Select ALL rows with WHERE statement
View as plain text  
2005/9/18, Jasper Bryant-Greene <jasper@stripped>:
> Alvaro Cobo wrote:
> > Thanks Pooly and Peter:
> >
> > The problem is that in the same php page I would like to choose either the
> > calculation from an especific year or the calculation from the whole table
> > using URL.
> 
> The same page can easily handle both.
> 
> <?php
> $sql = "SELECT * FROM mytable";
> 
> if(isset($_GET['year']) && !empty($_GET['year'])) {
>         $sql .= " WHERE year=" . intval($_GET['year']);
> }
> 
> $result = mysql_query($sql);
> ?>


Well, if you have control on everything, this approach would be the
best, no trick, easy to understand and maintain.

-- 
Pooly
Webzine Rock : http://www.w-fenec.org/
Thread
Select ALL rows with WHERE statementAlvaro Cobo17 Sep
  • Re: Select ALL rows with WHERE statementPooly17 Sep
  • Re: Select ALL rows with WHERE statementPeter Brawley17 Sep
  • Re: Select ALL rows with WHERE statementAlvaro Cobo18 Sep
    • Re: Select ALL rows with WHERE statementJasper Bryant-Greene18 Sep
      • Re: Select ALL rows with WHERE statementPooly18 Sep
    • Re: Select ALL rows with WHERE statementPeter Brawley18 Sep