close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

repeat region

Thread began 10/04/2018 6:38 am by Jamie | Last modified 10/04/2018 10:01 am by Ray Borduin | 191 views | 1 replies |

Jamie

repeat region

Hey Ray

Have got a recordset that is providing the content for a couple of elements on a page.

The rs is

<?php
$OfficeLocations = new WA_MySQLi_RS("OfficeLocations",$DBConnection,0);
$OfficeLocations->setQuery("SELECT * FROM service_contents2 WHERE Live = 1 ORDER BY ServicesOrder ASC");
$OfficeLocations->execute();
?>



The first code block I only want a specific row to be returned using a specific column ServicesID where the value would be 1

The second codeblock is a repeat using the same recordset and I want to only show the code <p>Also find us at:</p> once after the first loop and then not again

<?php
$wa_startindex = 0;
while(!$OfficeLocations->atEnd()) {
$wa_startindex = $OfficeLocations->Index;
?>
<p><strong style="text-transform:uppercase;"><?php echo($OfficeLocations->getColumnVal("ServicesTitle")); ?> -</strong>
<?php if ("".($OfficeLocations->getColumnVal("Address1")) ."" != "") { ?>
<?php echo($OfficeLocations->getColumnVal("Address1")); ?>,
<?php } ?>
<?php if ("".($OfficeLocations->getColumnVal("Address2")) ."" != "") { ?>
<?php echo($OfficeLocations->getColumnVal("Address2")); ?>,
<?php } ?>
<?php if ("".($OfficeLocations->getColumnVal("Town")) ."" != "") { ?>
<?php echo($OfficeLocations->getColumnVal("Town")); ?>,
<?php } ?>
<?php if ("".($OfficeLocations->getColumnVal("County")) ."" != "") { ?>
<?php echo($OfficeLocations->getColumnVal("County")); ?>
<?php } ?>
<?php if ("".($OfficeLocations->getColumnVal("PostCode")) ."" != "") { ?>
<?php echo($OfficeLocations->getColumnVal("PostCode")); ?>
<?php } ?>
</p>
<p>Also find us at:</p>
<?php
$OfficeLocations->moveNext();
}
$OfficeLocations->moveFirst(); //return RS to first record
unset($wa_startindex);
unset($wa_repeatcount);
?>



Is it possible to do both with the same recordset or would I need to use 2?

Thanks

Jamie

Sign in to reply to this post

Ray BorduinWebAssist

I think you just need:
SQL:
SELECT * FROM service_contents2 WHERE Live = 1 ORDER BY ServicesID=1 DESC, ServicesOrder ASC

php:
<?php

if ($OfficeLocations->Index === && $OfficeLocations->TotalRows 1) {
?>
                <p>Also find us at:</p>
<?php
}
?>
Sign in to reply to this post
Did this help? Tips are appreciated...

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