Jump to content

check if a record exist inside (or before?) a while loop


jeff5656

Recommended Posts

Below is a snippet where I pull a record from a  table.  I want to display

this line echo "the record doesn't exist";

if the record doesn't exist.  How do I do this?

Also I'm not sure WHER i put this.  It an't be inside the while loop since that's not run f the record doesn't exist. If I put it outside the while oop it gets displayed even if the record exists!

 

<?php
  $consultsq3 = "SELECT * FROM icu INNER JOIN family ON icu.id_incr = family.pt_id AND icu.id_incr = ' " . $row['id_incr'] . " '"; 

$result3 = mysql_query ($consultsq3) or die ("Invalid query: " . mysql_error ());
 while ($row3 = mysql_fetch_assoc ($result3)) {
	echo "the record doesn't exist";

	if ($row3['family_date'] == $current_date) {
		?><a  href="newfamily.php?id=<?php echo $row['id_incr']; ?>"><img src="../consults/images/familycheck.jpg" alt="m&m" width="80" height="20" border="0" /> </a><?php
		}


}

?>

I do not know ow to use foreaches that's why I have the While.  I guess the empty solution doesn't work with my code?

Ok, so if that's th case, how can I customize the foreac with my code?  What is $index and $value?  Do I still have to use $row['fieldname']?

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.