Jump to content

Using returned sql query values as variables


wright67uk

Recommended Posts

How can i put returned values from an sql query, into variables.

If the returned values from a query were; email1@com, email2@com, email3@com

how would i go about puting them into variables?

 

$value1 = (1st returned value from my sql query, in this case it would be email1@com)

$value2 = (2nd returned value from my sql query, in this case it would be email2@com)

$value3 = (3rd returned value from my sql query, in this case it would be email3@com)

 

$code = $_GET['postcode'];
$message = $_GET['message'];
$emailad = "[email protected]";
$shortcode = substr($code,0,2);
$result = mysql_query("SELECT email FROM treesurgeons WHERE postcode like '%" . $shortcode . "%' ORDER BY companyName LIMIT 3")
or die(mysql_error());  
echo "<h2>Business Names:</h2>";                     
while ($row = mysql_fetch_array( $result )) 
{
$message .= "\r\n". $row['email'] ;
}
echo nl2br ($message); 
mail( "$emailad", "Header","$message" );
echo "<br>" . "Thank you for using our mail form.";
?>
</body>
</html>

 

Thankyou for any ideas, or suggestions.

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.