Need PHP help

Tharindu DR

Well-known member
  • Jan 29, 2007
    3,201
    245
    63
    Im creating a search page.
    I need to search few data bases within one page so I used a como box to change tables, I dont know about PHP sooo this might be wrong.

    If some one know a better way pls help me thanx.

    Here is The Form :

    <form id="form1" name="form1" method="post" action="">
    <label>Search :
    <input type="text" name="q" id="q" />
    </label>
    <label>
    <input type="submit" name="btn" id="btn" value="Search" />
    </label>
    <label>
    <select name="lst" id="lst">
    <option value="<?php $table = 'book_new_item';?>">Books</option>
    <option value="<?php $table = 'comp_new_item'; ?>">Computers</option>
    <option value="<?php $table = 'mob_new_item' ;?>">CellPhones</option>
    <option value="<?php $table = 'clothe_new_item'; ?>">Clothing</option>
    <option value="<?php $table = 'camera_new_item'; ?>">Cameras</option>
    <option value="<?php $table = 'dvd_new_item' ;?>">DVDs</option>
    <option value="<?php $table = 'sport_new_item'; ?>">Sporting</option>
    <option value="<?php $table = 'toy_new_item' ;?>">Toys</option>
    <option value="<?php $table = 'music_new_item' ;?>">Musical</option>
    <option value="<?php $table = 'other_new_item' ;?>">Others</option>
    </select>
    </label>
    </form>


    Here is the SQL : ( Both in the same page)

    mysql_select_db($database_localhost, $localhost);
    $query_search = sprintf("SELECT topic, detail, name, `datetime`, reply FROM $table WHERE topic LIKE %s", GetSQLValueString("%" . $colname_search . "%", "text"));
    $query_limit_search = sprintf("%s LIMIT %d, %d", $query_search, $startRow_search, $maxRows_search);
    $search = mysql_query($query_limit_search, $localhost) or die(mysql_error());
    $row_search = mysql_fetch_assoc($search);
     

    Tharindu DR

    Well-known member
  • Jan 29, 2007
    3,201
    245
    63
    I used Dreamweaver to create this page.. All Db connections are Ok. Problem is I cant change the database .
     

    Tharindu DR

    Well-known member
  • Jan 29, 2007
    3,201
    245
    63
    icreations said:
    Send To Blaka Ban.. ubata PHP ekka Pissuwak hadila wage..:P he he ammo mama nam danne na..:P ;)

    Sorry Blacki Is not awalable...
    UU ta mata wada pissu hadila inne :P
     

    kosandpol

    Well-known member
  • Jun 10, 2008
    45,329
    1,492
    113
    should'nt your code be reading the value of lst and assigning it to $table before running the sql codes ?