close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

MySQLi Search to Results Page

Thread began 3/12/2015 2:23 pm by Cameron | Last modified 3/16/2015 9:36 am by Jason Byrnes | 4343 views | 4 replies |

Cameron

MySQLi Search to Results Page

Do you have a tutorial, video, forum thread etc that shows how to create a search form that will
populate results on a results page using MySQLi SB? I'm looking to recreate the product search and product results pages created in Data Assist
but in My SQLi.

If not, do you have a simple example of these pages in MySQLi that I could look at in code?

Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

There isn't a tutorial or video for this. and depending on the complexity of the search you are trying to build, you may be better of sticking with data Bridge to create this, for example if you are trying to create a key word search, that is going to be difficult to accomplish as it will take custom coding.

for a fairly simple search:

Create a Search form on your search page. the search form should use the get method.

Then on the results page, create the recordset to filter the results.

in the where clause, create a condition for each search form element. for example if the search form searches the products table and has an element for ProductName create the recordset as:

SELECT * FROM products
WHERE (ProductName = paramProductName OR -1 = paramProductName1)

in the variables section, create 2 variables as:
Name: paramProductName
Type: Text
Default value: -1
Runtime value: $_GET['ProductName']

Name: paramProductName1
Type: Text
Default value: -1
Runtime value: $_GET['ProductName']

Sign in to reply to this post

Cameron

Many thanks Jason. I'll give it a shot.

Sign in to reply to this post

Cameron

It's returning something, which is a good thing, but not filtering. I changed the variable from ProductName to ProductMetaKeywords, since that is the area of products I am searching. Maybe that is the problem? Perhaps you can have a look here.
My search page form is as follows (very simplified pages):

<form class="" id="" name="" method="get" action="resultsTEST.php">
<fieldset class="" id="Search">
<input id="ProductMetaKeywords" name="ProductMetaKeywords" type="text" value="<?php echo((isset($_GET["ProductMetaKeywords"])?$_GET["ProductMetaKeywords"]:"")); ?>" class="formTextfield_Medium" tabindex="4" title="Please enter a value.">
<span class="buttonFieldGroup" >
<input type="submit" value="Search" class="formButton unstyled" id="Search" name="Search" />
</span>
</fieldset>
</form>


My results page looks like this:

<?php require_once('Connections/MySQLi_CKS.php'); ?>
<?php require_once('webassist/mysqli/rsobj.php'); ?>
<?php
$rsKeySearch = new WA_MySQLi_RS("rsKeySearch",$MySQLi_CKS,9);
$rsKeySearch->setQuery("SELECT * FROM products WHERE (ProductMetaKeywords = ? OR -1 = ?)");
$rsKeySearch->bindParam("s", "".$_GET['ProductMetaKeywords'] ."", "-1"); //paramProductMetaKeywords
$rsKeySearch->bindParam("s", "".$_GET['ProductMetaKeywords'] ."", "-1"); //paramProductMetaKeywords1
$rsKeySearch->execute();
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
<?php
while(!$rsKeySearch->atEnd()) {
?>
<div>
Results:<?php echo($rsKeySearch->getColumnVal("ProductID")); ?><?php echo($rsKeySearch->getColumnVal("ProductName")); ?></div>
<?php
$rsKeySearch->moveNext();
}
$rsKeySearch->moveFirst(); //return RS to first record
?>

</body>
</html>

I'm just trying to get a simple search that will return results from the WebAssist ecommerce database filtering by input "included" in the keywords. Help?

Sign in to reply to this post

Jason ByrnesWebAssist

"by input "included" "


Right the example i gave uses an EQUAL query. if you want to create a INCLUDED query, change the = to LIKE on the first comparison, and the first variable, change the type to Includes Text

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...