wildcard in SQL is %, so your query looks like:

$query_search1 = "SELECT * FROM secureworks WHERE $varSort_search1 LIKE
'%$varText_search1%'";


[EMAIL PROTECTED] wrote:

>Howdy all!
>
>I've built a page in Dreamweaver MX that uses PHP for scripting.  I
>can get
>data out of my mysql database but I need to be able to search for
>wildcards.
>currently it only matches 100% exact queries.
>Below is the code that is at the beggining of the PHP page.
>-----------
>$varSort_search1 = "%";
>if (isset($HTTP_POST_VARS["Sort"])) {
>  $varSort_search1 = (get_magic_quotes_gpc()) ?
>$HTTP_POST_VARS["Sort"] :
>addslashes($HTTP_POST_VARS["Sort"]);
>}
>$varText_search1 = "%";
>if (isset($HTTP_POST_VARS["Text"])) {
>  $varText_search1 = (get_magic_quotes_gpc()) ?
>$HTTP_POST_VARS["Text"] :
>addslashes($HTTP_POST_VARS["Text"]);
>}
>mysql_select_db($database_CATCH, $CATCH);
>$query_search1 = sprintf("SELECT * FROM secureworks WHERE %s LIKE
>'%s'",
>$varSort_search1,$varText_search1);
>$search1 = mysql_query($query_search1, $CATCH) or die(mysql_error());
>$row_search1 = mysql_fetch_assoc($search1);
>$totalRows_search1 = mysql_num_rows($search1);
>
>-------------
>
>Does anyone have any ideas?
>
>Thanks,
>John Cole, TCISA
>
>
>  
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to