Jump to content

Gentlemen... 'Recordset Variables'


Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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;

?>

 

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.