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

Best Way To Proceed

Thread began 1/06/2022 3:45 am by yogastudents362523 | Last modified 1/13/2022 9:28 am by Brant | 16 views | 3 replies |

yogastudents362523

Best Way To Proceed

Hello,

This is not about an error, so no real need--or urgency to--respond.

I do not like amending code for my needs or purposes, because only being a relatively unfamiliar amateur, it leads to errors. The "while" statement the MySQLi extension placed on my page did not give me enough control over the output. I found that I instead needed a do-while loop. I first had to create my solution procedurally elsewhere, and then gradually adapt to object-oriented.

Here is the solution I came up with:

<?php if ($mySaturdayClasses->TotalRows > 0) { // Show if mysqli recordset not empty ?>
<p><span class="cancelledtext">Classes held on:

<?php
$previous = date('M');
echo "<strong>";
echo $previous;
echo "</strong>";
$wa_startindex = $mySaturdayClasses->Index;
do {

if (!(date('M', strtotime($mySaturdayClasses->getColumnVal("classdate"))) == $previous))
{
echo "<strong>";
echo "| ";
echo date('M', strtotime($mySaturdayClasses->getColumnVal("classdate")));
echo "</strong>";
$previous = date('M', strtotime($mySaturdayClasses->getColumnVal("classdate")));
}
echo " " . date('jS', strtotime($mySaturdayClasses->getColumnVal("classdate")));
?>
<?php $mySaturdayClasses->moveNext();
} while (!$mySaturdayClasses->atEnd()) ; ?>
<?php $mySaturdayClasses->moveFirst(); //return RS to first record
unset($wa_startindex);
unset($wa_repeatcount); ?>

</span></p>
<?php } // Show if mysqli recordset not empty ?>

That solution was based on this query (generated by MySQLi):

<?php
$mySaturdayClasses = new WA_MySQLi_RS("mySaturdayClasses",$mysqli_workshops,0);
$mySaturdayClasses->setQuery("SELECT * FROM workshops.saturdayssundays WHERE (saturdayssundays.classdate BETWEEN (DATE_ADD(CURDATE(), INTERVAL 0 MONTH)) AND (DATE_ADD(CURDATE(), INTERVAL 5 MONTH))) AND (WEEKDAY(saturdayssundays.classdate)=5) ORDER BY saturdayssundays.classdate");
$mySaturdayClasses->execute();
?>

I just want to know if there was a way to achieve the same end ENTIRELY using WebAssist tools, and that I somehow missed. I have some more complex tasks I must accomplish that will appear later in this project, and if I can avoid hand-coding to minimize my risks, that is what I would prefer.

Thank you,
KAB

Sign in to reply to this post

yogastudents362523

If it helps you can see the solution I generated in the location at the URL in the private area.
Thank you.

Sign in to reply to this post

Ray BorduinWebAssist

You need some hand code, but you can certainly do the loop with the webassist repeat region instead of your for loop... something like:

php:
<?php if ($mySaturdayClasses->TotalRows 0) { // Show if mysqli recordset not empty ?>

<?php
$previous 
date('M');
?>
<p><span class="cancelledtext">Classes held on:
 <strong><?php echo $previous?></strong>
<?php
$wa_startindex 
0;
while(!
$mySaturdayClasses->atEnd()) {
  
$wa_startindex $mySaturdayClasses->Index;
?>
<?php
if (!(date('M'strtotime($mySaturdayClasses->getColumnVal("classdate"))) == $previous)) {
?>
<strong>| 
<?php echo date('M'strtotime($mySaturdayClasses->getColumnVal("classdate"))); ?>
</strong>
<?php
  $previous 
date('M'strtotime($mySaturdayClasses->getColumnVal("classdate")));
}
echo 
" " date('jS'strtotime($mySaturdayClasses->getColumnVal("classdate")));
?>
<?php
  $mySaturdayClasses
->moveNext();
}
$mySaturdayClasses->moveFirst(); //return RS to first record
unset($wa_startindex);
unset(
$wa_repeatcount);
?>
</span></p>
<?php // Show if mysqli recordset not empty ?>
Sign in to reply to this post
Did this help? Tips are appreciated...

yogastudents362523

Hello,

Thank you very much for your help, yesterday.
KAB

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