wannes Posted November 6, 2011 Share Posted November 6, 2011 My apologize if this should be here since this involves SQL. My user can register himself ( just an email ) to a mail list. He will get a mail after that, but the message in the mail should differ: If there are under 100 people in the DB he should get something like " you are one of the 100 first people ", if there are more then 100 people it should say " sorry, to late ". I can seem to get it to work so help would be awesome ( ps, I kinda need an anwser fast :s ) $sqlInsert = "INSERT INTO j5_maillist (email) VALUES('$email')"; $sql = "SELECT COUNT(email) FROM j5_maillist AS aantalEmails"; $result = mysql_query($sql); if( mysql_num_rows($result) <= "3" ){ $message = 'you are one of the 100 first people '; } else { $message = 'sorry, to late '; } $to = $email; $subject = 'Nihonto Appreciation Day'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'To: '.$email.'' . "\r\n"; $headers .= 'From: Nihonto Appreciation Day' . "\r\n"; mail($to, $subject, $message, $headers); return mysql_query($sql); Link to comment https://forums.phpfreaks.com/topic/250572-mail-message-depends-on-nr-of-people/ Share on other sites More sharing options...
Gotharious Posted November 6, 2011 Share Posted November 6, 2011 You set if count = or less than three it would let him register <? $sql = "SELECT COUNT(email) FROM j5_maillist AS aantalEmails"; $result = mysql_query($sql); if( mysql_num_rows($result) <= "3" ){ $message = 'you are one of the 100 first people '; } else { $message = 'sorry, to late '; } ?> You should set that to 100 if( mysql_num_rows($result) <= "100" ){ Link to comment https://forums.phpfreaks.com/topic/250572-mail-message-depends-on-nr-of-people/#findComment-1285668 Share on other sites More sharing options...
Pikachu2000 Posted November 6, 2011 Share Posted November 6, 2011 That SELECT COUNT() query will never return more than one result, which will contain the number of records it matched. Link to comment https://forums.phpfreaks.com/topic/250572-mail-message-depends-on-nr-of-people/#findComment-1285673 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.