Problem with simple Looping, need helps
Posted: Mon Nov 30, 2009 6:56 pm
I wish to tell all members about ticket that is available. When registered, members are given an option to choose which destination (country) information they wish to get. If they chose more than one country then all will be stored into my database with xx,yy,zz format eg:
Brazil, United States, Mexico
This will result : All registration number and country will appeared together with user email which is used for mail()
But the problem is that $email still appear (which means that mail() will be still executed) although no records was found
Can anyone help me arrange this code, they must be wrongly looped
Brazil, United States, Mexico
Code: Select all
<?php require_once('config.php');
$query1="SELECT * FROM ticket";
$sql=mysql_query("SELECT * FROM passenger LIMIT 2 OFFSET 0 ");
while($array1=mysql_fetch_assoc($sql)){
$subscountry1=$array1['subs_country'];
$subscountry2= explode(",", $subscountry1);
for($i = 0; $i < count($subscountry2); $i++){
$subscountry[$i] = $subscountry2[$i];
$query_action1=mysql_query($query1);
$num1=mysql_num_rows($query_action1);
if(!empty($num1)){
while($array=mysql_fetch_assoc($query_action1)){
$id=$array['id'];
$registration=$array['reg_no'];
$country=$array['country'];
$email=$array1['email'];
if($subscountry[$i]==$country){
echo $id." ".$registration." ".$country." ";
}
}
}
}
mail($email,"xxxxxx","xxxxxx","xxxxxx")."<br>";
}
?>But the problem is that $email still appear (which means that mail() will be still executed) although no records was found
Can anyone help me arrange this code, they must be wrongly looped