savagenoob Posted October 22, 2010 Share Posted October 22, 2010 After doing a mysql_query and pulling data into an array like: $polquery = mysql_query("SELECT * FROM disclosures WHERE transid = '$transid'"); while($something = mysql_fetch_array($polquery){ $status = $something['complete']; } I need to cycle through the array $status to see if all values = "accept", I'm not sure how to do this... or just forgot. Maybe just do a while($status == "accept")? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 22, 2010 Share Posted October 22, 2010 Why not just do it in the while() loop? <?php $polquery = mysql_query("SELECT * FROM disclosures WHERE transid = '$transid'"); while($something = mysql_fetch_array($polquery) ) { if( $something['complete'] == 'accept' ) { //Do something } else { // Do something else } } ?> Quote Link to comment Share on other sites More sharing options...
savagenoob Posted October 22, 2010 Author Share Posted October 22, 2010 Maybe I'm not seeing it but it will loop through like 5 database entries and all of them have to = "accept". Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 22, 2010 Share Posted October 22, 2010 I think I was making an edit while you were typing . . . Quote Link to comment Share on other sites More sharing options...
savagenoob Posted October 22, 2010 Author Share Posted October 22, 2010 I dont see the edit? That will just ck each entry to see if it = "accept", I need all 5 to = "accept" Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 22, 2010 Share Posted October 22, 2010 Right, and if any value in the while loop doesn't == 'accept' it goes to the else{ }, where you can kill the script, or anything else you'd like to do to handle it. Unless I'm missing something, this is what you've described. If I've misunderstood you, let me know. Quote Link to comment Share on other sites More sharing options...
savagenoob Posted October 22, 2010 Author Share Posted October 22, 2010 I basically am making clients accept disclosures, when all the disclosures are accepted, show a link to move to next page. So, I only need to show the link if all of them = "accept, else, nothing. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 22, 2010 Share Posted October 22, 2010 How about this then, this should work just fine for what you're describing. <?php $all_accepted = TRUE; $polquery = mysql_query("SELECT * FROM disclosures WHERE transid = '$transid'"); while($something = mysql_fetch_array($polquery) ) { if( $something['complete'] != 'accept' ) { $all_accepted = FALSE; } } if( $all_accepted === TRUE ) { // display link echo '<a href="link_to_next_page.php">Click to proceed</a>'; } ?> Quote Link to comment Share on other sites More sharing options...
savagenoob Posted October 22, 2010 Author Share Posted October 22, 2010 Ahhh yes, thanks man. Quote Link to comment 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.