Jump to content

Check if all values in array = accept


savagenoob

Recommended Posts

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")?

Link to comment
Share on other sites

 

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
   }
}
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>';
}
?>

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.