Jump to content

Liste PHP/SQL


Go to solution Solved by BlackPage,

Recommended Posts

Posted

Bonjour à tous,

Je voudrais savoir comment m'y prendre pour faire plus simple. En effet, j'ai environ 300 mails et j'imagine qu'il y a beaucoup plus simple que de faire ce que je fais trois cents fois 😀.

<?php
$pre_classement_mail = "SELECT mail FROM membre";
$connect_classement_mail = $connect->query($pre_classement_mail);
while ($classement_mail = mysqli_fetch_array($connect_classement_mail))
{
$mail[] = $classement_mail['mail'];
}

$liste_mail = $mail[0].','.$mail[1].','.$mail[2].','.$mail[3].','.$mail[4].','.$mail[5].','.$mail[6].','.$mail[7];
?>

 

Je vous en remercie d'avance.

  • Solution
Posted

Salut, si tu fais une concaténation en texte à la fin, autant faire :

<?php
$pre_classement_mail = "SELECT mail FROM membre";
$connect_classement_mail = $connect->query($pre_classement_mail);
$liste_mail = '';
while ($classement_mail = mysqli_fetch_array($connect_classement_mail))
{
$liste_mail .= $classement_mail['mail'] . ', ';
}
$liste_mail = substr($liste_mail, 0, strlen($liste_mail)-2) // pour supprimer la dernière virgule
?>

 

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...