php - Browser hangs and crashes when using a while loop -
i executing 2 queries , evaluating following conditions each record:
- if
$production_query->row->0
equal$jobcard_query->row->0
- if
$production_query->row->1
equal$jobcard_query->row->1
when true, should display results of $production_query
.
however, when using while
statement, browser takes long time respond , crashes.
can suggest solution?
my code:
$query = " select job_card_num , die_qty,id sample_jobcard order id desc” $production_query = mysql_query($query,$connection1); $query1 = "select job_card_num , die_qty,id com_jobcard order id desc "; $jobcard_query = mysql_query($query1,$connection1); while ($row = mysql_fetch_array($production_query)) { while( $row1 = mysql_fetch_array($jobcard_query)) { while (($row1[0] == $row[0]) && ($row1[1] == $row[1])) { echo $row[0] . $row[1]. $row[2]'<br>'; } } }
try changing query this:
$query = "select sample_jobcard.job_card_num jobcardnum, sample_jobcard.die_qty dieqty, sample_jobcard.id jid, com_jobcard.job_card_num, com_jobcard.die_qty, com_jobcard.id sample_jobcard join com_jobcard on sample_jobcard.job_card_num = com_jobcard.job_card_num , sample_jobcard.die_qty = com_jobcard.die_qty order sample_jobcard.id desc"; $jobcard_query = mysql_query($query); if($jobcard_query && mysql_num_rows($jobcard_query) > 0) { while ($row = mysql_fetch_array($jobcard_query)) { echo $row['jobcardnum']." ".$row['dieqty']." ".$row['jid']."<br>"; } }
Comments
Post a Comment