$sqlWork = "SELECT * FROM work WHERE user_id = '$_SESSION[user_id]'";
$resultWork = $connection->query($sqlWork);
$rowWork = $resultWork->fetch_assoc();
(I would add an image if I had the reputation)
do {
echo "{$rowWork['work']}";
} while ($description = mysqli_fetch_array($resultWork));
use:
while($rowWork = $resultWork->fetch_assoc()){
echo $rowWork['work'];
}
I see that you are not using parametrized query, your code is vulnerable to SQL injection attack, you can avoid it by using prepared statement (parametrized)
$sqlWork = "SELECT * FROM work WHERE user_id = '$_SESSION[user_id]'";
$resultWork = $connection->query($sqlWork);
while ($description = mysqli_fetch_array($resultWork)){
echo $description['work'];
}
You can also do this based on these:
foreach
Use when iterating through an array whose length is (or can be) unknown.
for
Use when iterating through an array whose length is set, or, when you need a counter.
while
Use when you're iterating through an array with the express purpose of finding, or triggering a certain flag.
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.