Strange problem with a join
Posted: Tue Oct 08, 2002 12:35 am
I have a site where there are two separate mailing lists, one for free subscribers and one for paying. I am able to send a newsletter to either list, prior to doing that I run a test to see how many addresses are on each list, a simple $mysql_numrows($sql); Each returns the proper number, ahhh, but when I combine the two lists instead of the proper amount of rows being returned (which is 95, 9 from free list, 86 from paid) I get 774.
heres the code, tell me what you see.
As always any help is greatly appreciated
heres the code, tell me what you see.
Code: Select all
<?php
if($_POSTїwho] == 1):
$sql = "select email from mailinglist"; //9 on this mailing list
elseif($_POSTїwho] == 2):
$sql = "select email from members"; //86 on this mailing list
elseif($_POSTїwho] == 3):
$sql = "select mailinglist.email, members.email from mailinglist,members"; //should return 95 but returns 774
endif;
$res = mysql_query($sql) or die ("Could not select email addresses.");
$num_rows = mysql_numrows($res);
//print"$num_rows";
$count = 1;
while ($count <= $num_rows):
$row = mysql_fetch_array($res);
$email = $rowї"email"];
mail("$email", "$_POSTїsubject]", $body, $headers);
$count = $count + 1;
endwhile;
?>