Server-side data and WHERE clausole in SQL

Server-side data and WHERE clausole in SQL

gabrielegabriele Posts: 2Questions: 0Answers: 0
edited May 2011 in General
Hi,
I have the feeling this will be one of the most silly questions posted in the forum, but actually I can't find a specific answer to this.
I need to retrieve records from a db table using the WHERE clause on a "flag" field, in order to get only records associated to a specific category. Is this possible?

Replies

  • drrockdrrock Posts: 33Questions: 0Answers: 0
    edited May 2011
    Hi Gabriele,

    I think you should be able to modify the example server_processing.php file provided by Allan.

    Look near line 119 for the SQL variable $sQuery. You should see:
    [code]
    /*
    * SQL queries
    * Get data to display
    */
    $sQuery = "
    SELECT SQL_CALC_FOUND_ROWS ".str_replace(" , ", " ", implode(", ", $aColumns))."
    FROM $sTable
    $sWhere
    $sOrder
    $sLimit
    ";
    [/code]

    So for example you'd change to something like: "SELECT SQL_CALC_FOUND_ROWS FROM tablename WHERE someflag =='somecatergory' FROM $sTable
    $sWhere
    $sOrder
    $sLimit";

    I'm assuming you are using PHP but if not I think there were example server processing files in other program languages.

    Cheers,
  • gabrielegabriele Posts: 2Questions: 0Answers: 0
    edited June 2011
    Thank you for the reply drrock.
    I think there is a mistake in you example because you have FROM xxx two times in the same SQL.
    Btw, I have put the clause WHERE cat='2' as initial value of the variable $sWhere (line 87 more or less, I have modified the original php file several times) and it works fine now.
    The only issue is that when I start typing inside the search field I can see/find also the records with a different flag.
    In any case this is a minor thing, but if you have any idea you are welcome :)
    Thank you again.
This discussion has been closed.