Jump to content

[SOLVED] WHERE won't select the correct records


Recommended Posts

This is weird.  I select from this database and run a while loop:

<?php
if(isset($_POST['so'])) {
$_SESSION['so'] = $_POST['so'];
$so = $_POST['so'];
} elseif (isset($_SESSION['so'])) {
$so = $_SESSION['so'];
} else {
$so = 'a';
}
...snip....
$query = "SELECT * FROM active_consults WHERE signoff_status = '$so' ".
	"ORDER BY rcf_date2 DESC";
$results = mysql_query ($query) or die (mysql_error());
while ($row = mysql_fetch_assoc ($results)) {

 

Later in the code, inside this while loop I do this:

 

$count=0;
$query2 = "SELECT * FROM active_consults WHERE signoff_status = 's' ";
	$results2 = mysql_query ($query) or die (mysql_error());
	while ($signoff = mysql_fetch_assoc ($results2)) {
			echo $signoff['patient_name'];
			echo $signoff['mrn'] ." ";
			echo $signoff['signoff_status']."<br>";
			if ($signoff['mrn']==$row['mrn']){
			echo "match!<br>";
			$count++;
		        }
	}
	if ($count>0){
		echo $count." previous consult";if ($count>1){echo"s";}
	}

 

But the records from $signoff are ONLY signoff_status= 'a' even though I specifically said WHERE signoff_status = 's'.

Why is it not selecting the correct records that match signoff_status "s" in that second query?  Is it because I can't query the same table inside a while loop until that loop is done?  Just a guess..

Read this

$query2 = "SELECT * FROM active_consults WHERE signoff_status = 's' ";
$results2 = mysql_query ($query) or die (mysql_error());

 

dose it really look right ?

look 2 times

 

hit:

use the variables you set ;)

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.