Answer the question
In order to leave comments, you need to log in
How to fetch data from database in php?
I tried to output like this, but nothing happens:
<div class="review-row">
<?php
$con=mysqli_connect("localhost","root","root","review");
if (!$con) {
die("Connection failed: " . mysqli_connect_error());
}
$result = mysqli_query("SELECT * FROM reviews");
mysqli_close();
while($row = mysqli_fetch_array($result)){
?>
<div class="block-test">
<div class="review">
<div class="review-wrapper">
<span class="review-item-text"><?php echo $row['content']?></span>
<div class="review-item-order"><?php echo $row['email']?></div>
<div class="review-item-row">
<div class="review-item-username"><?php echo $row['name']?></div>
<div class="review-item-date">10 мая 2020, 17:06</div>
</div>
</div>
</div>
</div>
<?php } ?>
Answer the question
In order to leave comments, you need to log in
You never have to ask "how to do this and that" if you obviously know how to do it, and have already done it .
It is necessary to ask, " how to figure out why it does not work ." To do this, follow the recommendations from here
In particular, before connecting to the database, write
ini_set('display_errors',1);
error_reporting(E_ALL);
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question