SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Jan 2005
    Location
    bahrain
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to get selected data form data base

    hi
    i want to know that if i have a table with fname,sname,age,sex and now i have a html page on it options to search from database any of these fields from check boxes means multiple also can be selected e.g i select fname and sname only from form.now how can i get data from database,what will be query,becoz thier will be a lot of choices for users to search.
    thanks
    its urgent plz

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    153 Post(s)
    Tagged
    3 Thread(s)
    in your form you would have checkboxes for each item, named as fname etc.

    on your php page (NOT HTML), you would have.
    PHP Code:
    $query "select * from table where 1=1 ";
    if(isset(
    $_POST['fname'])) {
    $query .= "and fname = '"$_POST['fname'] . "'";
    }
    if(isset(
    $_POST['sname'])) {
    $query .= "and sname = '"$_POST['sname'] . "'";
    }
    $query_run mysql_query($query); 
    Something like that!

    SpikeZ
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •