Note that there are some explanatory texts on larger screens.

plurals
  1. POmysql - find match in comma seperated text field
    primarykey
    data
    text
    <p>I am having problems with output from my (MySQL) database.</p> <p>attractionData database</p> <pre><code> id | tags ------------------------------------- 1 | castle a, castle b, fakecastle c 2 | museum a, fakemuseum b, museum c ... </code></pre> <p>And on a site I have an input field, which has autoSuggest function. So in my jQuery I have an .keyup event, which send data to ajax file, and the ajax file outputs the list of suggestions (autosuggest).</p> <p>So now if I type in the input "castle a..." it will output the "1" (im outputting the id). And if i type in "museum a" it will return "2".</p> <p>So my question is... Is it somehow possible that if I would type in "fakecastle" that it would return "1"? I know this could be done with the <code>explode(',', $string)</code>.</p> <p>I've been messing around with FIND_IN_SET(), but I somehow didn't achieve the result I wanted. So I am still stucked with </p> <p><code>mysql_query("SELECT tags FROM attractionData WHERE (tags LIKE '$search%') ")</code> $search = text from the input field.</p> <p>EDIT</p> <pre><code>if(isset($_POST['search']) == true &amp;&amp; empty($_POST['search']) == false){ $search = $_POST['search']; $search = mysql_real_escape_string($search); $query = mysql_query("SELECT tags FROM attractionData WHERE (tags LIKE '$search%') ") while(($row = mysql_fetch_assoc($query)) !== false){ echo "&lt;li class='auto'&gt;".$row['friendEmail'] ."&lt;/li&gt;"; } </code></pre> <p>Any help would be appreciated</p> <p>Ty, Sebastian</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