do while with two conditions
Posted: Mon Feb 25, 2008 1:23 pm
Hey guys,
I have the following code that is working great:
This code is really used by another page that effectively bundles my invoices based on the customer id. Some customers have one and others have 50 to 60. The other page uses this one to email the html output of iv.php. Okay so the new twist that I now have to add is I need to regulate how many invoices it bundles at a time.
It is working great if I have a customer with 30 or less but the guys with 50-60 are killing me. Lets say I need to limit it to 20. I know I could do this:
I really need the conditions to be while ($custid == $rowivhead1['CUST_ID']) or ( $num <=20 ) whichever comes first. I tried ($custid == $rowivhead1['CUST_ID'] or $num <=20) with a test of one invoice but it runs the script a second time (with errors that stop the script).
How can I define two conditions. Remember that if either one is true the script needs to terminate.
I have the following code that is working great:
Code: Select all
do {
$queryivhead = "SELECT * FROM ivheadtemp order by CUST_ID ASC";
$result=mysql_query($queryivhead);
$rowivhead = mysql_fetch_assoc($result);
$custid = $rowivhead ['CUST_ID'];
$ivpass = $rowivhead ['INVOICE_NO'];
$idpass = $rowivhead ['SO_NO'];
include 'iv.php';
mysql_query("INSERT INTO track (TRACK_SO_NO, TRACK_STATUS, TRACK_NOTES) VALUES ('".$idpass."','25','".$statusname."')");
mysql_query("DELETE FROM ivheadtemp WHERE INVOICE_NO=$ivpass");
$queryivhead1 = "SELECT * FROM ivheadtemp order by CUST_ID ASC";
$result1=mysql_query($queryivhead1);
$rowivhead1 = mysql_fetch_assoc($result1);
} while ($custid == $rowivhead1['CUST_ID']);
It is working great if I have a customer with 30 or less but the guys with 50-60 are killing me. Lets say I need to limit it to 20. I know I could do this:
Code: Select all
$num = 1;
while ( $num <=20 )
{
$num = $num + 1;
}
How can I define two conditions. Remember that if either one is true the script needs to terminate.