close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

converting a rs to allow my pagination to work

Thread began 7/15/2019 10:55 am by Jamie | Last modified 7/18/2019 10:39 am by Ray Borduin | 29 views | 5 replies |

Jamie

converting a rs to allow my pagination to work

Hey Ray

Have set up a results page - in the first instance, content is filtered by 'productcategories' and want to add pagination using the below rs but I cannot get the select statements correct in the 2nd code block below (the first code block works fine without my pagination)

So I want to 'convert' this

<?php
$Categories = new WA_MySQLi_RS("Categories",$DBConnection,0);
$Categories->setQuery("SELECT productcategories.*, productcategories_2.CategoryName AS parentcategoryname, productcategories.CatPermalink, productcategories_2.CatPermalink AS parentpermalink, products.* FROM productcategories LEFT OUTER JOIN productcategories AS productcategories_2 ON productcategories_2.CategoryID = productcategories.CategoryParentID LEFT OUTER JOIN products ON products.ProductCategoryID = productcategories.CategoryID AND products.ProductLive = 1 WHERE productcategories.Live = 1 AND productcategories.CatPermalink = ? ORDER BY products.ProductDate ASC");
$Categories->bindParam("s", "".$_GET["perm"] ."", "-1"); //permparam
$Categories->execute();
?>


to this

<?php
$maxRows_Categories =15;
$Categories = new WA_MySQLi_RS("Categories",$DBConnection,$maxRows_Categories);
$Categories->setQuery("SELECT ");
$Categories->bindParam("s", "".$_GET["perm"] ."", "-1"); //permparam
$Categories->execute();

$CategoriesTotal = new WA_MySQLi_RS("CategoriesTotal",$DBConnection);
$CategoriesTotal->setQuery("SELECT count(1) a");
$CategoriesTotal->execute();
$Categories_Total = (int)$CategoriesTotal->Results[0]['a'];
$Req_Pages = ceil($Categories_Total/$maxRows_Categories);
?>



Am also trying to get the recordset to allow me to show alternate content if the category holds 0 products
Thanks

Jamie

Sign in to reply to this post

Ray BorduinWebAssist

I'm really confused about your updated code. You have an empty select statement, then a count statement in a separate recordset. I'm not sure what you are trying to do here, but the approach seems wrong. We may need to have a phone conversation and screen sharing so I can understand what you are trying to do and suggest the right way to go about it.

Sign in to reply to this post

Jamie

Hey Ray

I specifically left the second code block rs select statements blank as these are the ones I am trying to add the 'converted' select statement from the fist one into. Just copying the select from the 1st code block directly binto the 2nd cause an error

I purely set it up that way so that you could see the general structure of the RS that I needed to create with the 2nd code block

I am trying to replicate the pagination aspect from the attached page if that helps

Sign in to reply to this post

Ray BorduinWebAssist

I don't see where GalleryTotal is used on the page. I also am not familiar with count(1) in a SQL statement, so I'm not sure why it is necessary. Can't you use the ->TotalRows attribute of the original query?

Sign in to reply to this post

Jamie

The rs you helped me with a few months back and set it up that way....so am unable to answer why you wpould use count(1) or GalleryTotal - its just what you decided to do

Sign in to reply to this post

Ray BorduinWebAssist

I'm going to have to do screen sharing to figure out why I did that. It doesn't seem like it would be necessary, but I'm sure if I dig around I can figure out what I was doing and come up with a good solution.

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