Page 1 of 1

Help with DW Horizontal Repeat Region

Posted: Fri Jul 27, 2007 4:34 am
by prasitc2005
Dear Gurus

Please help how to solve this code problem in DW. The problem is that I can't see the payment due after repeat all the product items. The do while loop don't cover the rest of the table display. If I put while at the end, the payment due is shown twice and it looks ugly.

Here's the code:

Code: Select all

<tr>
<?php
$rs_order_endRow = 0;
$rs_order_columns = 5; // number of columns
$rs_order_hloopRow1 = 0; // first row flag
do {
if($rs_order_endRow == 0  && $rs_order_hloopRow1++ != 0);
?>	
<td align="left"><a rel="nofollow" target="_blank" href="http://www.test.com/price_details.php?code=<?php echo $row_rs_order['code']; ?>"><?php echo $row_rs_order['name']; ?> <?php echo $row_rs_order['colour']; ?> <?php echo $row_rs_order['watt']; ?> <?php echo $row_rs_order['lamptype']; ?> <?php echo $row_rs_order['mounting']; ?></a></td>
      <td align="center"><?php echo $row_rs_order['code']; ?></td>
      <td align="center"><?php echo $row_rs_order['price']; ?></td>
      <td align="right"><?php echo $row_rs_order['qty']; ?></td>
      <td align="right"><?php echo $row_rs_order['totunit_price']; ?></td>
</tr>
<?php  $rs_order_endRow++;
if($rs_order_endRow >= $rs_order_columns) {
?>	 
  
<?php
$rs_order_endRow = 0;
}
} while ($row_rs_order = mysql_fetch_assoc($rs_order));
if($rs_order_endRow != 0) {
while ($rs_order_endRow < $rs_order_columns) {
;
$rs_order_endRow++;
}
echo("</tr>");
}?>	
<tr>
  <td colspan="5" align="left"><!--DWLayoutEmptyCell-->&nbsp;</td>
  </tr>
	<tr bgcolor="#ffffff">
      <th colspan="4" align="left">Total(Excl VAT & Shipping fees)</th>
      <th align="right"><?php echo $row_rs_order['total_price']; ?></th>
    </tr>
    <tr bgcolor="#ffffff">
      <th colspan="4" align="left">Shipping fees(UK delivery only)</th>
      <th align="right"><?php echo $row_rs_order['ukship']; ?></th>
    </tr>
    <tr bgcolor="#ffffff">
      <th colspan="4" align="left">VAT 17.5%</th>
      <th align="right"><?php echo $row_rs_order['tax']; ?></th>
    </tr>
    <tr bgcolor="#ffffff">
      <th height="21" align="left" valign="top"><span class="style3">Payment Due</span></th>
      <th height="21" align="left" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</th>
      <th height="21" align="left" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</th>
      <th height="21" align="left" valign="top"><span class="style3"><?php echo $row_rs_order['items']; ?></span></th>
      <th align="right"><span class="style3"><?php echo $row_rs_order['grand_total']; ?></span></th>
</tr>
    <tr>
      <th height="21" colspan="5" align="left" valign="top"><span class="style3">* Please recheck client's credit card details. </span></th>
</tr>

Onion - Edited the thread title to remove pointless '::::::::highlighting!!!!!:::::::::'.

Re: Help with DW Horizontal Repeat Region

Posted: Fri Jul 27, 2007 5:44 am
by aceconcepts
prasitc2005 wrote:Dear Gurus

Code: Select all

while ($row_rs_order = mysql_fetch_assoc($rs_order));
if($rs_order_endRow != 0) {
while ($rs_order_endRow < $rs_order_columns) {
;
$rs_order_endRow++;
}
Line 4 ";" looks incorrect!

Re: Help with DW Horizontal Repeat Region

Posted: Fri Jul 27, 2007 8:43 am
by Chalks
prasitc2005 wrote: } while ($row_rs_order = mysql_fetch_assoc($rs_order));
if($rs_order_endRow != 0) {
while ($rs_order_endRow < $rs_order_columns) {
;
$rs_order_endRow++;
}
echo("</tr>");
}?>
edit: never mind... I only see the error that was mentioned above... the thing I'm looking at is a do/while loop.


It looks to me like there are two errors, actually. The first while loop doesn't have any {} and the second loop has a blank line. Actually, I'm curious, does a blank line like this:

Code: Select all

while(true)
{
;
}
I'm pretty sure that you're allowed to do that in some languages (though it's pointless). Does it really mess up php code?

Re: Help with DW Horizontal Repeat Region

Posted: Fri Jul 27, 2007 9:36 am
by onion2k
Chalks wrote:

Code: Select all

while(true)
{
;
}
I'm pretty sure that you're allowed to do that in some languages (though it's pointless). Does it really mess up php code?
That would result in an infinite loop that ran until the script timeout limit was reached.

Posted: Fri Jul 27, 2007 9:44 am
by Chalks
well, yeah... I wasn't thinking when I made that example. I was just asking about the blank line. Does the blank line really screw it up as aceconcepts seemed to think, or would the script just skip past the blank line?

Re: Help with DW Horizontal Repeat Region

Posted: Fri Jul 27, 2007 9:47 am
by superdezign
onion2k wrote:
Chalks wrote:

Code: Select all

while(true)
{
;
}
I'm pretty sure that you're allowed to do that in some languages (though it's pointless). Does it really mess up php code?
That would result in an infinite loop that ran until the script timeout limit was reached.
I believe he was just giving an example. ;)
The original script doesn't have any while(true) loops in it. Though, it does have a completely wasteful loop.

Code: Select all

while ($rs_order_endRow < $rs_order_columns) {
;
$rs_order_endRow++;
}
I have an alternative to that.

Code: Select all

$rs_order_endRow = ceil($rs_order_columns);

Re: Help with DW Horizontal Repeat Region

Posted: Fri Jul 27, 2007 9:48 am
by superdezign
aceconcepts wrote:
prasitc2005 wrote:Dear Gurus

Code: Select all

while ($row_rs_order = mysql_fetch_assoc($rs_order));
if($rs_order_endRow != 0) {
while ($rs_order_endRow < $rs_order_columns) {
;
$rs_order_endRow++;
}
Line 4 ";" looks incorrect!
That is actually the end of a do...while loop.

Re: Help with DW Horizontal Repeat Region

Posted: Fri Jul 27, 2007 9:50 am
by superdezign
This if-statement look incorrect to me. It doesn't have any contents, and it alters a variable that I believe isn't even tested against 0. I think that'd be ++$foo, though I could be mistaken.
prasitc2005 wrote:

Code: Select all

do {
if($rs_order_endRow == 0  && $rs_order_hloopRow1++ != 0);
?>

Re: Help with DW Horizontal Repeat Region

Posted: Fri Jul 27, 2007 9:51 am
by Chalks
aceconcepts wrote:
prasitc2005 wrote:Dear Gurus

Code: Select all

while ($row_rs_order = mysql_fetch_assoc($rs_order));
if($rs_order_endRow != 0) {
while ($rs_order_endRow < $rs_order_columns) {
;
$rs_order_endRow++;
}
Line 4 ";" looks incorrect!
superdezign wrote:That is actually the end of a do...while loop.
Actually... I think the end of the do/while loop is on line 1 of the above snippet.

I didn't see the do loop when I posted earlier though, good catch. :)

Re: Help with DW Horizontal Repeat Region

Posted: Fri Jul 27, 2007 9:55 am
by superdezign
Chalks wrote:Actually... I think the end of the do/while loop is on line 1 of the above snippet.
Yes. That's what I was referring to. I was under the assumption that the semi colon at the end of the while loop was what he was referring to, but I see now. "Line 4." Hehe. I thought he meant "for" somehow, which still didn't make sense to me. :P

Solved!

Posted: Fri Jul 27, 2007 5:17 pm
by prasitc2005
Actually after a day of despair, I have found a perfect solution

Code: Select all

<?php do {?>
<td align="left"><a rel="nofollow" target="_blank" href="http://www.test.com/price_details.php?code=<?php echo $row_rs_order['code']; ?>"><?php echo $row_rs_order['name']; ?> <?php echo $row_rs_order['colour']; ?> <?php echo $row_rs_order['watt']; ?> <?php echo $row_rs_order['lamptype']; ?> <?php echo $row_rs_order['mounting']; ?></a></td>
      <td align="center" valign="top"><?php echo $row_rs_order['code']; ?></td>
      <td align="center" valign="top"><?php echo $row_rs_order['price']; ?></td>
      <td align="center" valign="top"><?php echo $row_rs_order['qty']; ?></td>
      <td align="right" valign="top"><?php echo $row_rs_order['totunit_price']; ?></td>
</tr>
<?php } while ($row_rs_order = mysql_fetch_assoc($rs_order));?>
then copy a second recordset called $rs_order2 and replace the field that must not be repeated.