Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

how to make searching php for receive file

baebae Member Posts: 45
this is the form. i want the code able to read from table in the database.






Any Field





Title 




Author


 Year









Comments

  • AgbagbaraAgbagbara Member Posts: 24
    could you be a little bit more explanative
  • baebae Member Posts: 45
    the keyword will be include title, author, year. it will invoke from database that store the source file.
  • AgbagbaraAgbagbara Member Posts: 24
    [code]
    Keyword

    Any Field
    Title 

    Author
     Year
    [/code]

    if your table is called "ALL_BOOKS", and has the following columns TITLE,AUTHOR and YEAR.
    Lets say you have a keyword textbox called "keyword", when u post the form to the processing page,
    you would have to do the following
    [code]
    $d_keyword = $_POST["keyword"];
    $check_field = $_POST["keyword"];
    d_where = array();
    switch($check_field){
    case "TITLE":
    $d_where[] = " `TITLE` like '%".$d_keyword."%' ";
    break;
    case "AUTHOR":
    $d_where[] = " `AUTHOR` like '%".$d_keyword."%' ";
    break;
    case "YEAR":
    $d_where[] = " `YEAR` like '%".$d_keyword."%' ";
    break;
    default:
    $d_where[] = " (`TITLE` like '%".$d_keyword."%' or `AUTHOR` like '%".$d_keyword."%' or `YEAR` like '%".$d_keyword."%' )";
    break;
    }
    $where_str = (count(d_where)> 0)?" where ".implode(" and ",d_where):"";
    $d_qry = sprintf("select * from ALL_BOOKS %s , %s, %s", $where_str,$limit_str,$order_str);
    [/code]

    This is just some sketchy details on how you would go about it,

    Let me know if it helps or not.
  • baebae Member Posts: 45
    $d_keyword = $_POST["keyword"];
    $check_field = $_POST["keyword"];
    d_where = array();
    switch($check_field){
    case "TITLE":
    $d_where[] = " `TITLE` like '%".$d_keyword."%' ";
    break;
    case "AUTHOR":
    $d_where[] = " `AUTHOR` like '%".$d_keyword."%' ";
    break;
    case "YEAR":
    $d_where[] = " `YEAR` like '%".$d_keyword."%' ";
    break;
    default:
    $d_where[] = " (`TITLE` like '%".$d_keyword."%' or `AUTHOR` like '%".$d_keyword."%' or `YEAR` like '%".$d_keyword."%' )";
    break;
    }
    $where_str = (count(d_where)> 0)?" where ".implode(" and ",d_where):"";
    $d_qry = sprintf("select * from ALL_BOOKS %s , %s, %s", $where_str,$limit_str,$order_str);


    how to add u didnt mention <? ?>
Sign In or Register to comment.