I am creating a web application which requires a kind of series of related data from database, and those data should be separated by commas,
For hint : I am fetching those values with while loop
<?php while ( $writer = mysqli_fetch_assoc($sqi8)) { ?>
<?=$writer['fullname']; ?>
<?php } ?>
So in the code above there more than one names from the database and i want to separate them with comma when they are fetched
A cleaner way to achieve that would be this:
<?php
$fullNames = [];
while ($row = mysqli_fetch_assoc($sqi8)) {
$fullNames[] = $row["fullname"];
}
foreach ($fullNames as $fullName) { ?>
<a href="cast-profile.php?cast=<?=$fullName;?>"><?=$fullName; ?> </a>,
<?php
}
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.