close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Show/hide region if rows contain/don't contain

Thread began 1/26/2020 1:52 am by Sweens | Last modified 1/30/2020 7:17 pm by Ray Borduin | 403 views | 5 replies |

Sweens

Show/hide region if rows contain/don't contain

I have a recordset that returns 2 page types (PgTypeID is the field name).

I have 2 repeat regions on the page, based on the value of the PgTypeID.

The recordset may have 10 records with PgTypeID = 5, but none with PgTypeID=2.

There is a 'show if recordset is empty' behaviour, which obviously works if no records are returned - but how can I do it so that 'if there are no rows where PgTypeID = 2' show 'No pages of this type' ?

What I have so far (simplified):

<?php
$wa_startindex = 0;
while(!$rsPages->atEnd()) {
$wa_startindex = $rsPages->Index;
?>
<?php if ($rsPages->getColumnVal("PgTypeID") <> "2") { ?>
<p>display contents</p>
<?php } ?>
<?php
$rsPages->moveNext();
}
$rsPages->moveFirst(); //return RS to first record
unset($wa_startindex);
unset($wa_repeatcount);
?>

Many thanks

Chris

Sign in to reply to this post

Ray BorduinWebAssist

Maybe add a separate recordset to return the number of rows with each page type. Then you could use those recordsets to create the Show If message.

Sign in to reply to this post
Did this help? Tips are appreciated...

Sweens

Thanks Ray - I'll try that.

Cheers
Chris

Sign in to reply to this post

Sweens

Actually, the easiest way would be to separate the recordset into 2, then just use the standard 'if recordset empty' behaviour. (which is what I originally had. I combined them trying to get fewer calls to the database on the page, assuming this would be quicker).

Cheers
Chris

Sign in to reply to this post

Ray BorduinWebAssist

You could use a single recordset if you wanted to create a more complex SQL statement like:

SELET COUNT(IF(PgTypeID= 5, 1, NULL)) AS Type5Count, COUNT(IF(PgTypeID= 2, 1, NULL)) AS Type2Count, * FROM...

But I'm not sure if it would be any more efficient than separate recordsets, so I still think adding recordsets to get the counts would be easier. If it did save any time it would be milliseconds and probably not worth the extra effort.

Sign in to reply to this post
Did this help? Tips are appreciated...

Sweens

Thanks Ray. I'll take your advice and go with separate recordsets.

Cheers
Chris

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