phpretard Posted May 15, 2008 Share Posted May 15, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/105822-while-loop-problem/ Share on other sites More sharing options...
phpretard Posted May 15, 2008 Author Share Posted May 15, 2008 Bad Question? Quote Link to comment https://forums.phpfreaks.com/topic/105822-while-loop-problem/#findComment-542395 Share on other sites More sharing options...
wildteen88 Posted May 15, 2008 Share Posted May 15, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/105822-while-loop-problem/#findComment-542400 Share on other sites More sharing options...
kenrbnsn Posted May 15, 2008 Share Posted May 15, 2008 The comparison operator for not equal is "!=", not "!==" Ken Quote Link to comment https://forums.phpfreaks.com/topic/105822-while-loop-problem/#findComment-542403 Share on other sites More sharing options...
phpretard Posted May 15, 2008 Author Share Posted May 15, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/105822-while-loop-problem/#findComment-542430 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.