Jump to content

While Loop Problem


phpretard

Recommended Posts

No matter how many $results there are it will only display include one page.

 

Do I need a foreach or something?

 

I think I realize that when the first if statement is met the while loop stops, but I don't know any solution.

 

 

 

$result = mysql_query("SELECT * FROM projects WHERE Cnumber='$Cnumber' ORDER by Pname");

while($row = mysql_fetch_array($result))
  {
  $id=$row['id'];
  $Pname=$row['Pname'];
  $pic=$row['pic'];
  $Cnumber=$row['Cnumber'];
  $approved=$row['approved'];
  $revise=$row['revise'];

if (($approved!=='')&&($revise=='')){include 'approved.php';}
if (($approved=='')&&($revise!=='')){include 'revise.php';}
if (($approved=='')&&($revise=='')){include 'pending.php';} 

}

 

There is one entry that mathes each if statement right now but only one will display.

Link to comment
Share on other sites

What is the purpose of this code:

if (($approved!=='')&&($revise=='')){include 'approved.php';}
if (($approved=='')&&($revise!=='')){include 'revise.php';}
if (($approved=='')&&($revise=='')){include 'pending.php';} 

What are you trying to do? You'll need to explain more.

 

Also loops do not stop if an if/else statement is present in the loop.

Link to comment
Share on other sites

I don't know if this helps my question become any more clear but this gives me the desired result.

 

The Query is different each time.  I am sure there is an easier way...but I don't know what it is.

 

 

$result = mysql_query("SELECT * FROM projects WHERE Cnumber='$Cnumber' AND revise !='' AND approved ='' ORDER by Pname");

while($row = mysql_fetch_array($result))
  {
  $id=$row['id'];
  $Pname=$row['Pname'];
  $pic=$row['pic'];
  $Cnumber=$row['Cnumber'];
  $approved=$row['approved'];
  $revise=$row['revise'];
  $details=$row['details'];
  $qty=$row['qty'];
  
$status="| Revision Requested";

include 'pages/secure/pages/projects/revise.php';

}

$result = mysql_query("SELECT * FROM projects WHERE Cnumber='$Cnumber' AND revise ='' AND approved ='' ORDER by Pname");

while($row = mysql_fetch_array($result))
  {
  $id=$row['id'];
  $Pname=$row['Pname'];
  $pic=$row['pic'];
  $Cnumber=$row['Cnumber'];
  $approved=$row['approved'];
  $revise=$row['revise'];
  $details=$row['details'];
  $qty=$row['qty'];
  
$status="| Pending Review";

include 'pages/secure/pages/projects/pending.php';

}

$result = mysql_query("SELECT * FROM projects WHERE Cnumber='$Cnumber' AND approved !='' ORDER by Pname");

while($row = mysql_fetch_array($result))
  {
  $id=$row['id'];
  $Pname=$row['Pname'];
  $pic=$row['pic'];
  $Cnumber=$row['Cnumber'];
  $approved=$row['approved'];
  $revise=$row['revise'];
  $details=$row['details'];
  $qty=$row['qty'];
  
$status="| Order Completed";  

include 'pages/secure/pages/projects/approved.php';

}

 

PS Thank you for the operator note

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.