Web Analytics Made Easy -
StatCounter a varible to select a table - CodingForum

Announcement

Collapse
No announcement yet.

a varible to select a table

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • a varible to select a table

    i have abou 6 tables that i want to search from, these
    tables are based i one database

    what i want to do is to use a varible to select the required
    table for the search to retrieve the correct results

    can some one help me please

    $query= "SELECT * FROM $gettable WHERE sname LIKE '$wsoft';";

    when i do the above code then an error is return due to the
    $gettable varible

    i think its a wrong syntax but i cannot find any examples anywhere here (forum) or in the books i have.

    if i have no solution then its gonna be multiple IF statments.
    something i just dont want to do (looks nasty)

    thanks
    bit rate on then off, whats the speed?

  • #2
    How you build the value for $query, is just like building any other querystring. Try

    $query= "SELECT * FROM " . $gettable . " WHERE sname LIKE '" . $wsoft . "'";

    --> drop the ; inside the string
    --> concatinate the strings and variable, instead of including them in the strings

    For debugging, make it
    $query= "SELECT * FROM " . $gettable . " WHERE sname LIKE '" . $wsoft . "'";
    die($query);

    and then load this page in the browser and look at the printed statement.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

    Comment

    Working...
    X