Jump to content

Getting Caught in a Loop


swatisonee

Recommended Posts

hi,

a. I have 2 Tables: Table A and Table B

b. I have to select all records from Table A that donot appear in Table B . 1 field in both is common .

c. I dont have a problem selecting data that appears in both tables where the same field is in common but
the reverse is getting caught in a loop and i'm not able to figure out what the error is.

d. The error is that the else statement gets executed.

Would appreciate some guidance pleas.e . Thanks.Swati

[code]$sqlb= "SELECT * FROM `Enq` WHERE  Category`!= 'D' && `Category`!= 'A' && fid='$fid'";
$resultb=mysql_query($sqlb);
if ($myrowb=mysql_fetch_array($resultb))
{
do
{
$enqid=$myrowb["Enqid"];

$sqlc="SELECT * FROM `order` WHERE `Enqid`= $enqid ";
if ( !@mysql_query($resultc) )
{

do {

     printf("<tr><td><input type=\"radio\" name=\"choice\" value=%d><td>
     <font size=2 face=Tahoma color=blue>%d<td>
     <font size=2 face=Tahoma color=blue>%s<td>
     <font size=2 face=Tahoma color=blue>%s<td>
</tr>",
  $myrowb["Enqid"],
   $myrowb["fid"],
  $myrowb["Company"],
  calculatedate($myrowb["Date"]) );

}
while ($myrowc = mysql_fetch_array($resultc));
}

}
while ($myrowb= mysql_fetch_array($resultb));
}

else {
    echo "Sorry, no records were found!";
}[/code]
Link to comment
https://forums.phpfreaks.com/topic/4692-getting-caught-in-a-loop/
Share on other sites

[!--quoteo(post=353947:date=Mar 11 2006, 05:37 PM:name=swatisonee)--][div class=\'quotetop\']QUOTE(swatisonee @ Mar 11 2006, 05:37 PM) [snapback]353947[/snapback][/div][div class=\'quotemain\'][!--quotec--]
hi,

a. I have 2 Tables: Table A and Table B

b. I have to select all records from Table A that donot appear in Table B . 1 field in both is common .

c. I dont have a problem selecting data that appears in both tables where the same field is in common but
the reverse is getting caught in a loop and i'm not able to figure out what the error is.

d. The error is that the else statement gets executed.

Would appreciate some guidance pleas.e . Thanks.Swati

[code]$sqlb= "SELECT * FROM `Enq` WHERE  Category`!= 'D' && `Category`!= 'A' && fid='$fid'";
$resultb=mysql_query($sqlb);
if ($myrowb=mysql_fetch_array($resultb))
{
do
{
$enqid=$myrowb["Enqid"];

$sqlc="SELECT * FROM `order` WHERE `Enqid`= $enqid ";
if ( !@mysql_query($resultc) ) // <-- look this line
{

do {

     printf("<tr><td><input type=\"radio\" name=\"choice\" value=%d><td>
     <font size=2 face=Tahoma color=blue>%d<td>
     <font size=2 face=Tahoma color=blue>%s<td>
     <font size=2 face=Tahoma color=blue>%s<td>
</tr>",
  $myrowb["Enqid"],
   $myrowb["fid"],
  $myrowb["Company"],
  calculatedate($myrowb["Date"]) );

}
while ($myrowc = mysql_fetch_array($resultc));
}

}
while ($myrowb= mysql_fetch_array($resultb));
}

else {
    echo "Sorry, no records were found!";
}[/code]
[/quote]
look lin 9 change '$resultc' to '$sqlc'

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.