Jump to content


Photo

Gentlemen... 'Recordset Variables'


  • Please log in to reply
4 replies to this topic

#1 fncuis

fncuis
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 08 September 2004 - 07:50 PM

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!

#2 morpheus.100

morpheus.100
  • Members
  • PipPipPip
  • Advanced Member
  • 145 posts

Posted 08 September 2004 - 10:02 PM

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);


#3 fncuis

fncuis
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 14 September 2004 - 12:19 PM

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;
?>



#4 fncuis

fncuis
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 14 September 2004 - 12:36 PM

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?

#5 morpheus.100

morpheus.100
  • Members
  • PipPipPip
  • Advanced Member
  • 145 posts

Posted 15 September 2004 - 10:14 PM

With regards the % being added you may have a JavaScript error in a DMX file. Make all values %s only.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users