Help with DW Horizontal Repeat Region

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
prasitc2005
Forum Commoner
Posts: 42
Joined: Thu Jul 13, 2006 7:14 am

Help with DW Horizontal Repeat Region

Post 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!!!!!:::::::::'.
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Help with DW Horizontal Repeat Region

Post 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!
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Re: Help with DW Horizontal Repeat Region

Post 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?
Last edited by Chalks on Fri Jul 27, 2007 9:52 am, edited 1 time in total.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Help with DW Horizontal Repeat Region

Post 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.
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Post 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?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Help with DW Horizontal Repeat Region

Post 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);
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Help with DW Horizontal Repeat Region

Post 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.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Help with DW Horizontal Repeat Region

Post 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);
?>
Last edited by superdezign on Fri Jul 27, 2007 9:52 am, edited 1 time in total.
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Re: Help with DW Horizontal Repeat Region

Post 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. :)
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Help with DW Horizontal Repeat Region

Post 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
User avatar
prasitc2005
Forum Commoner
Posts: 42
Joined: Thu Jul 13, 2006 7:14 am

Solved!

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