Jump to content

krisbadsg

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

krisbadsg's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. thank you very much for your reply but , i already tried this. but when a if condition is true the query is processing but OR clause is making a problem and giving an error.
  2. i am having the database consists of morethan one lac rows. we have a search option in our website to search the database for required information. the present code is like this: form.php `<input type="radio" name="tag" value="city" /> CITY <br/>` `<input type="radio" name="tag" value="name" /> NAME OF CUSTOMER <br/>` `<input type="radio" name="tag" value="amount" /> CHEQUE AMOUNT <br/>` `<input type="radio" name="tag" value="somethingelse" /> some thing else ` `Enter the part of any of the above Here :<input type="text" name="value" />` search.php `$tag = $_POST['tag'];` `$value = $_POST['value'];` `$query = "SELECT * FROM database WHERE $tag LIKE '%$value%' "` note: we always input the part field only. with this some times the output comes in thousands of rows. with which we are facing problems. we want to search the two or more fields for getting more precise results. hence i tried this form: `<h3 align="center">ENTER ALL OR DESIRED ITEMS YOU WANT TO SEARCH</h3>` `<div width="80%" align="center">` `<input type="text" name="city" /> CITY <br/>` `<input type="text" name="name" /> NAME OF THE CUSTOMER <br/>` `<input type="text" name="amount" /> AMOUNT <br/>` `<input type="text" name="somethingelse" /> SOME OTHER SEARCH FIELD </div> ` `$query = "SELECT * FROM database WHERE city LIKE %$city%' || name LIKE %$name%' || amount LIKE %$amount%' || somethingelse LIKE %$somethingelse%';` it worked in the mysql console, and even in our website when we give all the variables. but it displaying the entire database when we dont give even one field in the search box. i tried to assign NULL to the variable which was not given. it is also not worked. it works if any variable is replaced with NULL in the query. i don't know how to do that. i tried a lot of queries after searching in lot of code provider websites. but none of them gave the desired results.hence i request you to provide me a sql query code for search the database using all of the above fields or any two or even with one. the code must work independent of number of fields we entered.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.