开发者

php selecting bulk email and post

ive got over thousands my clients email in database.

sorting the email with php:

$q = $db->query("SELECT email FROM user LIMIT 200");
while($r = $q->fetch_array(MYSQLI_ASSOC)) :
  echo '<input type="checkbox" name="emailList" class="useremail" value="'.$r['email'].'">';开发者_如何学JAVA
endwhile;

anyone knows how to post the selected email only?. if possible with ajax jquery. well of course i will use phpmailer to post the email.


how do i echo out random email

query

SELECT email FROM user ORDER BY RAND() LIMIT 200

Generally, using ORDER BY RAND() is not a good idea. check here http://jan.kneschke.de/projects/mysql/order-by-rand/


You can SELECT random rows by using RAND();

$q = $db->query("SELECT email FROM user ORDER BY RAND() LIMIT 200");

Your second question is not clear though, you will need to change the value of the checkbox to the email address or an id relating to that email, maybe like this:

while($r = $q->fetch_array(MYSQLI_ASSOC)) :
  echo '<input type="checkbox" name="emailList" class="useremail" value="'.$r['email'].'">';
endwhile;

You can then access checked values of emailList by using $_POST or $_GET.

var_dump($_POST);

Or

var_dump($_GET);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜