Note that there are some explanatory texts on larger screens.

plurals
  1. POReturning rows from database based on search query
    primarykey
    data
    text
    <p>I am having a product table with following schema:</p> <p><code>products (itemname VARCHAR(50), itemid INT(10));</code></p> <p>Sample records are shown below (<code>itemname</code>, <code>itemid</code>):</p> <ul> <li><strong>blackberry curve 3g (black), 1</strong></li> <li><strong>samsung ace, 3</strong></li> <li><strong>blackberry curve 3g (white), 2</strong></li> <li><strong>apple iphone 4 32gb (black), 4</strong></li> </ul> <p>Now suppose user enters the query into the search box of the website and accordingly results are displayed. i.e. if user enters <code>blackberry</code> then Blackberry mobiles should be displayed</p> <p>I am looking answers for the following questions:</p> <ol> <li>How can search text be matched with the items? For example: user may enter <code>blackberry</code> in the search box then how it can be searched? Should I search for <code>blackberry</code> word as a sub-string of <code>itemname</code> column of the above table?</li> <li>If the user enters two words like: <code>apple 32gb</code>. Now if I use the above mentioned method of sub-string then it wont work because there is no row in the table having <code>apple 32gb</code> as sub-string. How to search in this case?</li> <li>If the user enters a very generic search text like: <code>mobiles</code>. In this case, all the mobile phones should be displayed. Matching the <code>itemname</code> as a sub-string will not work in this case also.</li> <li>User may enter search text: <code>apple 32gb black color</code>. In this case, apple products of 32GB capacity and black color should be displayed. </li> </ol> <p>I know that implementing the search 100% correct is not possible. I am just looking for hints/how to proceed. I am using PHP, MySQL, Apache. </p>
    singulars
    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