Jump to content

put while loop contents into one variable


jeff5656

Recommended Posts

Instead of echoing out this list of records, I want to put everything inside this while loop into $message so I can email the list.  How do I do this?

Here's the code that echoes it out to the screen:

$query2 = "SELECT * FROM `gpu` WHERE `signoff_status` = 'a' and `attg` = '". $whoto ."' ";

$result2 = mysql_query ($query2) or die ("Invalid query: " . mysql_error ());
while ($row2 = mysql_fetch_assoc ($result2)) {
echo "Patient:". $row2['patient'] . " MRN:  " . $row2['mrn'];
<br>
}

<?php
$message = "";
$query2 = "SELECT * FROM `gpu` WHERE `signoff_status` = 'a' and `attg` = '". $whoto ."' ";
$result2 = mysql_query ($query2) or die ("Invalid query: " . mysql_error ());
while ($row2 = mysql_fetch_assoc ($result2)) {
  $message .= "Patient:". $row2['patient'] . " MRN:  " . $row2['mrn'] . "\n<br>";
}
?>

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.