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

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Show if conditional region syntax

Thread began 10/27/2016 7:17 am by Nixtev | Last modified 10/27/2016 7:32 pm by Ray Borduin | 478 views | 4 replies |

Nixtev

Show if conditional region syntax

I'm busy converting a site with a lot of coding generated by ADDT and other PHP/MySQL extensions over to MySQLi and thought I'd better check before I go any further that what I've got is correct, or if it will cause me problems further down the line.

The code I had was

<?php
// Show IF Conditional TopMenu
if (@$row_Rs_siteinfomnu['site_menu'] >= "2"
AND
@$row_Rs_siteinfomnu['site_menu'] <= "4") {
?>

so does that simply become

<?php
// Show IF Conditional TopMenu
if ($Rs_siteinfomnu->getColumnVal("site_menu") >= "2"
AND
$Rs_siteinfomnu->getColumnVal("site_menu") <= "4") {
?>

or do I need to do anything else?

I also have this one that I need to convert as well but not yet sure if I'm heading in the right direction!

<?php // Hide if RS Field is Null
$field = $row_Rs_dog['photo1_copyr'];
if(strlen($field) > 0){
?>

which I've got as far as changing to

<?php // Hide if RS Field is Null
$field = $Rs_dog->getColumnVal("photo1_copyr");
if(strlen($field) > 0){
?>

but really not sure if that's going to be the right way to do it or not.

Thanks.

Sign in to reply to this post

Ray BorduinWebAssist

That all looks correct to me.

Sign in to reply to this post

Nixtev

Oh that's great thanks :)
I had hoped that these options would be available for the MySQLi extension by now as coding isn't my strongest point but needs must!

I've also got a nested repeat region that I'm a bit stuck with so while I think I've got the rest of it done, I don't know how to get this bit working so how would I go about this please as so far I just have a repeat region inside an repeat region?
I'm trying to get

<?php
while(!$detail2dogs_i->atEnd()) {
?>
<li><a href="dogpge.php?dog=<?php echo($detail2dogs_i->getColumnVal("dog_ID")); ?>"><?php echo($detail2dogs_i->getColumnVal("dog_titlepre")); ?> <?php echo($detail2dogs_i->getColumnVal("dog_showname")); ?></a></li>
<?php
$detail2dogs_i->moveNext();
}
$detail2dogs_i->moveFirst(); //return RS to first record
?>



to do what

<?php
if ($totalRows_Rs_dog_sec>0) {
$nested_query_detail2dogs = str_replace("123456789", $row_Rs_dog_sec['dogsection_ID'], $query_detail2dogs);
mysql_select_db($database_updates);
$detail2dogs = mysql_query($nested_query_detail2dogs, $updates) or die(mysql_error());
$row_detail2dogs = mysql_fetch_assoc($detail2dogs);
$totalRows_detail2dogs = mysql_num_rows($detail2dogs);
$nested_sw = false;
if (isset($row_detail2dogs) && is_array($row_detail2dogs)) {
do { //Nested repeat
?>
<li><a href="dogpge.php?dog=<?php echo $row_detail2dogs['dog_ID']; ?>"><?php echo $row_detail2dogs['dog_titlepre']; ?> <?php echo $row_detail2dogs['dog_showname']; ?></a></li>
<?php
} while ($row_detail2dogs = mysql_fetch_assoc($detail2dogs)); //Nested move next
}
}
?>



does. I need to filter the nested region to only show results relevant to it's parent value but am lost on how to do that.

The full block of old code is

(Old code)

<?php
mysql_select_db($database_updates, $updates);
$query_Rs_dog_sec = "SELECT dogsection_ID, dogsection_name, dogsection_display, dogsection_displayorder FROM dogsection WHERE dogsection_display = 'Y' ORDER BY dogsection_displayorder ASC";
$Rs_dog_sec = mysql_query($query_Rs_dog_sec, $updates) or die(mysql_error());
$row_Rs_dog_sec = mysql_fetch_assoc($Rs_dog_sec);
$totalRows_Rs_dog_sec = mysql_num_rows($Rs_dog_sec);

mysql_select_db($database_updates, $updates);
$query_detail2dogs = "SELECT dogs.dog_ID, dogs.dog_showname, dogs.dog_titlepre, dogs.dog_titleaf, dogs.dog_sex, dogs.dog_breedID, dogs.dog_sectionID, dogs.dog_owner, dogs.dog_breeder, dogs.dog_display, dogs.dog_displayorder, dogs.dog_sitedog_ID FROM dogs WHERE dogs.dog_sectionID=123456789 AND dogs.dog_owner='Y' AND dogs.dog_display = 'Y' AND dogs.dog_sitedog_ID = 1 ORDER BY dogs.dog_displayorder ASC";
$detail2dogs = mysql_query($query_detail2dogs, $updates) or die(mysql_error());
$row_detail2dogs = mysql_fetch_assoc($detail2dogs);
$totalRows_detail2dogs = mysql_num_rows($detail2dogs);

?>
<?php do { ?>
<!-- open li -->
<li>
<a href="dogsec.php?s=<?php echo $row_Rs_dog_sec['dogsection_ID']; ?>"><?php echo $row_Rs_dog_sec['dogsection_name']; ?></a>
<?php
// Show IF Conditional TopMenuDogSecs
if (@$row_Rs_siteinfomenu['site_menu'] >= "2") {
?>
<!-- open ul -->
<ul>
<?php
if ($totalRows_Rs_dog_sec>0) {
$nested_query_detail2dogs = str_replace("123456789", $row_Rs_dog_sec['dogsection_ID'], $query_detail2dogs);
mysql_select_db($database_updates);
$detail2dogs = mysql_query($nested_query_detail2dogs, $updates) or die(mysql_error());
$row_detail2dogs = mysql_fetch_assoc($detail2dogs);
$totalRows_detail2dogs = mysql_num_rows($detail2dogs);
$nested_sw = false;
if (isset($row_detail2dogs) && is_array($row_detail2dogs)) {
do { //Nested repeat
?>
<li><a href="dogpge.php?dog=<?php echo $row_detail2dogs['dog_ID']; ?>"><?php echo $row_detail2dogs['dog_titlepre']; ?> <?php echo $row_detail2dogs['dog_showname']; ?></a></li>
<?php
} while ($row_detail2dogs = mysql_fetch_assoc($detail2dogs)); //Nested move next
}
}
?>
<!-- close ul -->
</ul>
<?php }
// endif Conditional TopMenuDogSecs
?>
<!-- close li -->
</li>

<?php } while ($row_Rs_dog_sec = mysql_fetch_assoc($Rs_dog_sec)); ?>



so I've now got

(New code)

<?php
$Rs_dog_sec_i = new WA_MySQLi_RS("Rs_dog_sec_i",$updates_i,0);
$Rs_dog_sec_i->setQuery("SELECT dogsection_ID, dogsection_name, dogsection_display, dogsection_displayorder FROM dogsection WHERE dogsection_display = 'Y' ORDER BY dogsection_displayorder ASC");
$Rs_dog_sec_i->execute();
?>
<?php
$detail2dogs_i = new WA_MySQLi_RS("detail2dogs_i",$updates_i,0);
$detail2dogs_i->setQuery("SELECT dogs.dog_ID, dogs.dog_showname, dogs.dog_titlepre, dogs.dog_titleaf, dogs.dog_sex, dogs.dog_breedID, dogs.dog_sectionID, dogs.dog_owner, dogs.dog_breeder, dogs.dog_display, dogs.dog_displayorder, dogs.dog_sitedog_ID FROM dogs WHERE dogs.dog_sectionID=123456789 AND dogs.dog_owner='Y' AND dogs.dog_display = 'Y' AND dogs.dog_sitedog_ID = 1 ORDER BY dogs.dog_displayorder ASC");
$detail2dogs_i->execute();
?>
<?php
while(!$Rs_dog_sec_i->atEnd()) {
?>
<!-- open li -->
<li><a href="dogsec.php?s=<?php echo($Rs_dog_sec_i->getColumnVal("dogsection_ID")); ?>"><?php echo($Rs_dog_sec_i->getColumnVal("dogsection_name")); ?></a>
<?php
// Show IF Conditional TopMenuDogSecs
if ($Rs_siteinfomenu_i->getColumnVal("site_menu") >= "2") {
?>
<!-- open ul -->
<ul>
<?php
while(!$detail2dogs_i->atEnd()) {
?>
<li><a href="dogpge.php?dog=<?php echo($detail2dogs_i->getColumnVal("dog_ID")); ?>"><?php echo($detail2dogs_i->getColumnVal("dog_titlepre")); ?> <?php echo($detail2dogs_i->getColumnVal("dog_showname")); ?></a></li>
<?php
$detail2dogs_i->moveNext();
}
$detail2dogs_i->moveFirst(); //return RS to first record
?>
<!-- close ul -->
</ul>
<?php }
// endif Conditional TopMenuDogSecs
?>
<!-- close li -->
</li>
<?php
$Rs_dog_sec_i->moveNext();
}
$Rs_dog_sec_i->moveFirst(); //return RS to first record
?>



Thanks.

Sign in to reply to this post

Ray BorduinWebAssist

You have to move the recordset for the nested repeat into the while loop where you want it nested. That way it is recreated for each row and can be filtered based on the current row of the parent recordset.

Sign in to reply to this post

Nixtev

Thanks, I'm still trying to get my head around all the different looking code and that the "while" bit appears to have moved from the bottom of the block to the top now so I don't know how much of that old code block I can just borrow and change the obvious bits or if it all needs re-doing.

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