Note that there are some explanatory texts on larger screens.

plurals
  1. POFilter MYSQL where multiple fields can match URL PARAMETER. IN, LIKE or REGEXP?
    text
    copied!<p>i've created a page that displays all of the table results in a list, but if you select a category name, then it filters those results to all rows that match the category name in the URL(using friendly URL's) in either the <code>category_1</code> field or the <code>category_2</code> field. here's what i have now:</p> <pre><code>$colname_rs_categories = "-1"; if (isset($_GET['cat'])) { $colname_rs_categories = $_GET['cat']; } mysql_select_db($database_neonnettle, $neonnettle); $query_rs_categories = sprintf(" SELECT videos_id, DATE_FORMAT(date,'%%D %%M %%Y @ %%l.%%i %%p')date, thumb, title, sub_title FROM VIDEOS_view WHERE %s IN (category_1, category_2) ORDER BY videos_id DESC", GetSQLValueString($colname_rs_categories, "text") ); $query_limit_rs_categories = sprintf("%s LIMIT %d, %d", $query_rs_categories, $startRow_rs_categories, $maxRows_rs_categories); $rs_categories = mysql_query($query_limit_rs_categories, $neonnettle) or die(mysql_error()); $row_rs_categories = mysql_fetch_assoc($rs_categories); </code></pre> <p>Now this has worked great up to a point. for example: if the users selects the category <code>"Pop"</code>, then the URL will be <code>www.example.com/pop</code> and it will list all the results that match either <code>category_1</code> and/or <code>category_2</code> with <code>"Pop"</code>.</p> <p>The problem that i have is that if the category name is <code>"Pop Music"</code>, then the URL will be <code>www.example.com/pop-music</code> and this will then stop the results from being filtered as it no longer sees a match.</p> <p>I have been experimenting with <code>LIKE</code> and <code>REGEXP</code> but i've had no luck. I was thinking something like this (but not this as it doesn't work):</p> <pre><code>WHERE (category_1 REGEXP '%s' OR category_2 REGEXP '%s') </code></pre> <p>Any suggestions?</p>
 

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