0

after i have run my query on a mysql db how can i set the result to equal a variable that i will use later on in the page.

i have set the query up like this

<?php
$rand = rand (0, 100);	
$query = "SELECT broad1 FROM images_broad";
$result=mysql_query($query);

while($row=mysql_fetch_array($result, MYSQL_ASSOC)){
$send_mail =$row['broad1'];
}
		     
?>

i dont think the last line is correct though. could anyone please help.

2
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by kevin wood
1

you are pulling from all rows in the db. your variable will only display the last rows info. but yes that should work for using that var later in the page.

Votes + Comments
helpful
0

the end code look like this

$query = "SELECT sent_messages FROM email_count"or die(mysql_error());
$results = mysql_query($query);
$arr = mysql_fetch_array($results);
$sent_mail = $arr[0];

thanks for the reply though

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.