close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

MySQLi Database Search

Thread began 3/09/2016 2:35 pm by markdoyle87077 | Last modified 6/10/2016 4:15 pm by Ray Borduin | 484 views | 20 replies |

markdoyle87077

MySQLi Database Search

Since the MySQLi version of Data Bridge is still in the making I need help so I can move forward.

In order for me to move forward with my site I need help writing the MySQLi to provide the functionality of database search as mentioned in this tutorial http://www.webassist.com/tutorials/Checkbox-method-for-add-to-cart. I do use the checkbox method of adding multiple products at a time but I cannot re produce in MySQLi what Data Bridge can. I am happy pay premium support to get this solved.

Kind regards.

Sign in to reply to this post

Ray BorduinWebAssist

We can do this in a premium support ticket.

It is fairly simple... you use the same form setup, but don't use DataAssist search instead you use an "integer list" type parameter and use the implode() function to join the posted checkbox array into a comma separated list.

Everything else is the same.

Sign in to reply to this post

markdoyle87077

MySQLi Database Search

See pm

Sign in to reply to this post

Ray BorduinWebAssist

The products recordset would be something like:

php:
<?php

$rs_products 
= new WA_MySQLi_RS("rs_products",$dmbc_database,0);
$rs_products->setQuery("SELECT * FROM products WHERE visible =1 AND category = ? ORDER BY type, description ASC");
$rs_products->bindParam("s""".(isset($_GET['categories'])?$_GET['categories']:"")  ."""-1"); //colname
$rs_products->execute();
?>



The type recordset would be something like:

php:
<?php

$rs_type 
= new WA_MySQLi_RS("rs_type",$dmbc_database,0);
$rs_type->setQuery("SELECT DISTINCT typename, type FROM products WHERE visible =1 AND category = ? ORDER BY type ASC");
$rs_type->bindParam("s""".(isset($_GET['categories'])?$_GET['categories']:"")  ."""-1"); //colname
$rs_type->execute();
?>



You can update the ATC recordset to:

php:
<?php

$rs_ATC 
= new WA_MySQLi_RS("rs_ATC",$dmbc_database,0);
$rs_ATC->setQuery("SELECT * FROM products WHERE id IN (?)");
$rs_ATC->bindParam("il""".(isset($_POST['ATCCheck'])?implode(",",$_POST['ATCCheck']):"")  ."""-1"); //colname
$rs_ATC->execute();
?>



I'm just guessing the category field in your products table is named category and that is the field that the url parameter would match up with. If not, let me know. It would be easier in a screen sharing session because I could ask you about your database structure and verify it works by testing the page. If you do have issues, perhaps you could fill me in more about the database structure and give me FTP access and a URL so I can debug and test the code changes I'm suggesting.

Sign in to reply to this post

markdoyle87077

Hi Ray,

Sadly its not that easy for the first two recordsets. The database column is called categories and it could consist of Birthday Message Love Wedding Valentines so one product could be called in several different categories. When I did this in ASP I just had to use Database Search to filter the records based on the URL parameter. Give me some options for a screen share, as it seems it may be easier to do it that way

Sign in to reply to this post

Ray BorduinWebAssist

Will only one category be passed in through the url at a time? If so, you can just use:

php:
<?php

$rs_products 
= new WA_MySQLi_RS("rs_products",$dmbc_database,0);
$rs_products->setQuery("SELECT * FROM products WHERE visible =1 AND category LIKE ? ORDER BY type, description ASC");
$rs_products->bindParam("c""".(isset($_GET['categories'])?$_GET['categories']:"")  ."""-1"); //colname
$rs_products->execute();
?>


and

php:
<?php

$rs_type 
= new WA_MySQLi_RS("rs_type",$dmbc_database,0);
$rs_type->setQuery("SELECT DISTINCT typename, type FROM products WHERE visible =1 AND category LIKE ? ORDER BY type ASC");
$rs_type->bindParam("c""".(isset($_GET['categories'])?$_GET['categories']:"")  ."""-1"); //colname
$rs_type->execute();
?>
Sign in to reply to this post

markdoyle87077

I will updated all the recordsets and try the page and then come back to you with the results. Many thanks.

Sign in to reply to this post

markdoyle87077

The page works fine when I update the rs_products and rs_type recordsets but it throws the following error when I amend and the rs_ATC recordset:

Notice: Undefined variable: rsViewedProducts in C:\xampp\htdocs\dmbc\categories.php on line 32

Fatal error: Call to a member function bindParam() on null in C:\xampp\htdocs\dmbc\categories.php on line 32

I tried wrapping the recordset in an if statement to ensure that the form had posted. In the case the page loads no problem but then throws the error after I click a couple of products and then add them to the cart.

Update page attached.

Attached Files
categories.php
Sign in to reply to this post

Ray BorduinWebAssist

That should be:
ra_ATC
not
rsViewedProducts

on that line (32). I had copied it from another recordset and forgot to update the name.

Sign in to reply to this post

markdoyle87077

Okay page is running but selected products are not getting added to the cart. I think I have identified the issue and it relates back to the tutorial and it has to do with the quantity that gets added. My code is

$dmbc_in_stock_itemQuantity = floatval("".((isset($_POST["btnQuantity_".$row_rs_ATC['id']]))?$_POST["btnQuantity_".$row_rs_ATC['id']]:"") ."");

If I change this to

$dmbc_in_stock_itemQuantity = 1;

then 1 of everything I select gets added.

So what shall I set $dmbc_in_stock_itemQuantity to so it adds the correct quantities?

Sign in to reply to this post
loading

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...