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
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'
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.