Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP search result output different result if you give one letter only
    primarykey
    data
    text
    <p>The search code I am working works for the search if I put 2 or more letters but when I give it a query with one letter it gives me all of the lists of the data I have a where status like 'found' clause but it still gives me other results if I put a single letter. The search part works if I put two or more letters properly but if I put one letter it gives me different query result.</p> <p>Here is my SQL query </p> <pre><code>&gt; $searchtext = ''; if(isset($_GET['q'])) $searchtext = &gt; mysql_real_escape_string($_GET['q']); if($searchtext) { &gt; $per_page =16; &gt; $pages_query = mysql_query("SELECT COUNT('PersonID') FROM persons where firstname like '$searchtext' or &gt; lastname like '$searchtext' and status like 'found' "); &gt; $pages = ceil(mysql_result($pages_query,0) / $per_page); &gt; &gt; $page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1; &gt; $start = ($page - 1) * $per_page; &gt; &gt; &gt; // And set the first page $first_page = "1"; &gt; &gt; $num = mysql_num_rows($pages_query); &gt; $last_page = ($num / $per_page); &gt; $next_page = $page + 1; &gt; $last_page=$pages; &gt; &gt; &gt; &gt; $query=mysql_query("select * from persons where status like 'found' and firstname like '%$searchtext%' or lastname like &gt; '%$searchtext%' order by date desc LIMIT $start,$per_page "); &gt; &gt; $numrows = mysql_num_rows($query); &gt; &gt; &gt; } &gt; &gt; else { &gt; &gt; $per_page =16; &gt; $pages_query = mysql_query("SELECT COUNT('PersonID') FROM persons where status like 'found' "); &gt; $pages = ceil(mysql_result($pages_query,0) / $per_page); &gt; &gt; $page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1; &gt; $start = ($page - 1) * $per_page; &gt; $last_page=$pages; &gt; &gt; // And set the first page $first_page = "1"; &gt; &gt; &gt; $query=mysql_query("select * from persons where status like 'found' order by date desc LIMIT $start,$per_page "); &gt; $count=mysql_query("select * from persons where status like 'found'"); &gt; $numrows = mysql_num_rows($count); &gt; &gt; } </code></pre> <p>This screen shot is the default view. The query for this is <code>$query=mysql_query("select * from persons where status like 'found' order by date desc LIMIT $start,$per_page ");</code> <img src="https://i.stack.imgur.com/0GLwe.png" alt="1st screen shot"></p> <p>This screen shot is the search view when I search for <code>dan</code> in the default view for found and recieve this result this is the query I use for outputing. ` $query=mysql_query("select * from persons where status like 'found' and firstname like '%$searchtext%' or lastname like '%$searchtext%' order by date desc LIMIT $start,$per_page ");</p> <p>$numrows = mysql_num_rows($query);` <img src="https://i.stack.imgur.com/hPNPd.png" alt="2nd picture"></p> <p>The final picture shows that I searched letter <code>a</code>. The result that gave to me come from all fields. Also, I have a conflict that calls also the missing list I want to limit it only for the found only and that's also the problem with the query of the missing it also finds in whole fields of found.</p> <p>The SQL command I use here is the one in picture 2 <img src="https://i.stack.imgur.com/droIi.png" alt="picture3"></p>
    singulars
    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.
 

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