fncuis Posted September 8, 2004 Share Posted September 8, 2004 My dilemna is in the "advanced window" of the recordset creation in DWMX. My SQL statement is as follows: SELECT * FROM msds WHERE msds.`ref`LIKE '%sterm%' OR msds.description LIKE '%sterm%' OR msds.manufacturer LIKE '%sterm%' ORDER BY `ref` ASC Simple enough? However, when i do a search, all records are returned from the DB. I want only the record that is 'LIKE' that of the term entered in the search field of the search page. In ASP a simple "Request.QueryString['varName'] will suffice... from what i have researched for PHP, this statement should do the trick: Name: sterm Value: 1 Run-Time Value: $_GET['sterm'] Still no luck... Help is much appreciated! Thank you! Quote Link to comment Share on other sites More sharing options...
morpheus.100 Posted September 8, 2004 Share Posted September 8, 2004 If this fails then post a table dump structure with a line of data and I will have a crack at it. $colname_Recordset1 = "1"; if (isset($_GET['sterm'])) { $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['sterm'] : addslashes($_GET['sterm']); } mysql_select_db($database_preview, $preview); $query_Recordset1 = sprintf("SELECT * FROM msds WHERE msds.ref LIKE '%%%s%%' OR msds.description LIKE '%%%s%%' OR msds.manufacturer LIKE '%%%s%%' ORDER BY `ref` ASC", $colname_Recordset1); $Recordset1 = mysql_query($query_Recordset1, $preview) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); Quote Link to comment Share on other sites More sharing options...
fncuis Posted September 14, 2004 Author Share Posted September 14, 2004 The only difference i see here is that you added $colname_ to the recordset correct? Also, Guru, why is it that when you specify '%sterm%' in the SQL statement window of DW, in the advanced mode, when you switch to view the code in the document it totally changes it to: %%%%s% or something of that nature...? Anywho... here's the code: <?php $currentPage = $_SERVER["PHP_SELF"]; $maxRows_q1 = 50; $pageNum_q1 = 0; if (isset($_GET['pageNum_q1'])) { $pageNum_q1 = $_GET['pageNum_q1']; } $startRow_q1 = $pageNum_q1 * $maxRows_q1; $sterm_q1 = "1"; if (isset($_GET['sterm'])) { $sterm_q1 = (get_magic_quotes_gpc()) ? $_GET['sterm'] : addslashes($_GET['sterm']); } mysql_select_db($database_msdsphp, $msdsphp); $query_q1 = sprintf("SELECT * FROM msds WHERE manufacturer LIKE 'stermterm%%' OR description LIKE '%%%s%%' OR ref LIKE '%%%%s%%' ORDER BY msds.`ref`ASC", $sterm_q1); $query_limit_q1 = sprintf("%s LIMIT %d, %d", $query_q1, $startRow_q1, $maxRows_q1); $q1 = mysql_query($query_limit_q1, $msdsphp) or die(mysql_error()); $row_q1 = mysql_fetch_assoc($q1); if (isset($_GET['totalRows_q1'])) { $totalRows_q1 = $_GET['totalRows_q1']; } else { $all_q1 = mysql_query($query_q1); $totalRows_q1 = mysql_num_rows($all_q1); } $totalPages_q1 = ceil($totalRows_q1/$maxRows_q1)-1; ?> Quote Link to comment Share on other sites More sharing options...
fncuis Posted September 14, 2004 Author Share Posted September 14, 2004 I'd like to update the post by mentioning that the search results are refined, however, the search term is only functioning in the "description" column of the db. I have specified in the code to search for "sterm" in all columns of the db. Any ideas Guru? Quote Link to comment Share on other sites More sharing options...
morpheus.100 Posted September 15, 2004 Share Posted September 15, 2004 With regards the % being added you may have a JavaScript error in a DMX file. Make all values %s only. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.