Note that there are some explanatory texts on larger screens.

plurals
  1. POSearching in ajax does not return result with spaces
    primarykey
    data
    text
    <p>After clicking the search button in my page it typically outputs the result of the query. however i have a problem with regards to conditions where the value of the field has a white space. so what i am doing is to trim the string and look it up in the database using LIKE statement.</p> <pre><code> $(document).ready(function(){ $('#btnsearch').click(function(e) { $("#content0 #sub_cont0").load("view/search.php?document=&lt;?php echo $_GET['document']; ?&gt;&amp;stat=&lt;?php echo $_GET['stat']?&gt;&amp;ac=&lt;?php echo $_GET['ac']; ?&gt;&amp;fac=&lt;?php echo $_GET['fac']; ?&gt;&amp;val=" + $("#txtsearch").val() + "&amp;model=&lt;?php echo trim($_GET['model']);?&gt;"); $(".tblmodellist").fadeOut("slow"); }); }); </code></pre> <p>example i will search for the word "casing". under the category model = "Test Model". When this is queried in the database, it does not output anything using this query. NOTE: in the above script, I trimmed the model so the output will be "Test" only. But still it does not return my expected result set.</p> <pre><code> $sql = "SELECT * FROM $db WHERE ( FileName LIKE '%" . $id . "%' OR $title LIKE '%" . $id . "%' OR $no LIKE '%" . $id . "%' ) AND (Stat = '$stat' AND Model LIKE '%".$model."%') "; </code></pre> <p>What do you think is the problem in my ajax request? I have found earlier during my debug that when I put the $_GET['model'] in the center, it cuts down the query resulting in a NULL value, that is the reason why i put it in the end of the line.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload