Jump to content

Infinite loop problem with php and mysql


rdrews

Recommended Posts

Not sure if this should go in the mysql section or the php section so I'm putting it in both.  Sorry if that's not what I should do...

 

Okay, here's the code that I have...

 

<?php
function reportQuery($reportName, $accountNumber){
   $rq = "SELECT * FROM $reportName WHERE AccountNum = $accountNumber";
   $retq = mysql_query($rq);
   echo mysql_error();
   return $retq;
}

$query = "select * from accountinfo WHERE Paid = ''";
$rt = mysql_query($query);
echo mysql_error();

while($kt = mysql_fetch_array($rt)){
   echo "$kt[AccountNum] <br />";
   echo "<table border='1' cellspacing='1' cellpadding='1'><tr><th>Type</th><th>Account Number</th><th>Employee</th><th>Pay</th></tr>";      
   
   while($rd = mysql_fetch_array(reportQuery('adjustmentsreport', $kt[AccountNum]))){
      echo "<tr><td>Adjustment</td><td>$rd[AccountNum]</td><td>$rd[Name]</td><td>yes/no</td></tr>";
   }
   
   echo "</table>";
}
[code]

My accountinfo table has various records with a field called AccountNum that are all unique (no duplicates).  My adjustmentsreport table also has various records with a field called AccountNum that match numbers in the accountinfo table but are all again unique within the adjustmentsreport table. 

My problem is when I open this page and the code executes I get an infinite loop on the first matching AccountNum it finds.  I have looked over the code way too many times and I can't figure out what is going on.  Any help would be greatly appreciated!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.