Hi,
I have an email script which looks to my database for relevant records and then emails the relevant people in a while statement.
Problem is the variables won't seem to unset < maybe it's the wrong function?
Here's a basic idea of the code I'm using
$query = "SELECT url FROM mytable WHERE id ='whatever'";
$result = mysql_query($query) ;
while($row=mysql_fetch_array($result)){
$url = $row['url'];
if (!$url) {
$mailbody1 = "
<h3>1. You don't have a website?</h3>
";}
else {
$mailbody2 = "
<h3>1. You have a website</h3>
";}
$mailbody = $mailbody1.$mailbody2;
mail($to, $subject, $mailbody, $headers);
unset ($url);
}
The above works perfectly on the first loop after that it's like the variable result from the first loop still exists... I've try'd loads of similar methods none seem to work.
Senario A.
user id 1 -- does not have a url in database
user id 2 -- does have a url
The above code produces >
email
to user 1 = You don't have a website
email to user 2 = You don't have a website
You have a website
Hope that makes sense and I really hope someone can help.
Thanks in advance.
Lee.