The code below shows one email address as a output but I want to get a list of all
email addresses (seperated by comma) of customer table. How can I get that?
<?php
$SQLstring = "SELECT email FROM customers";
$QueryResult = @mysqli_query($DBConnect, $SQLstring)
or die("<p>Unable to execute the query.</p>" .
"<p> Error code " . mysqli_errno($DBConnect) . ":" . mysqli_error ($DBConnect))."</p>";
$NumRows = mysqli_num_rows($QueryResult);
if ($NumRows == 0)
{
echo "<p>No email found.</p>";
}
else
{
for($i = 1; $i <= $NumRows; $i++)
{
$Row = mysqli_fetch_row($QueryResult);
$email = stripslashes($Row[0]);
echo $email;
}
}
?>
This is
mysqlinotmysqlyou’re using so things work a little differently…Assuming you’ve created your mysqli connection with something like
$DBConnect = new msqli( ... );It’s probably better to store the result before you manipulate it; try something like: