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
https://forums.phpfreaks.com/topic/105822-while-loop-problem/
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
https://forums.phpfreaks.com/topic/105822-while-loop-problem/#findComment-542400
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
https://forums.phpfreaks.com/topic/105822-while-loop-problem/#findComment-542430
Share on other sites

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.