Hi,
Consider that I have these codes for connection:
In database.php:
<?php
$server_name = 'localhost';
$user_name = 'root';
$password = '';
$db_name = 'gallery';
$image_table_name = 'images';
$information_table_name = 'info';
$connection = new mysqli($server_name, $user_name, $password, $db_name);
if($connection->connect_error)
{
die("Connection to database failed".$connection->connect_error);
}
?>
in index.php:
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
require "../app/core/database.php";
$sql = "SELECT * FROM info limit 1";
$result = $connection->query($sql);
?>
I want to use While() loop between html codes more than once. The first loop works fine but next loops doesn’t work. There is no error.
For example I write:
<?php while($row = $result->fetch_assoc()) { ?>
html codes.......<?php $row['image_text'] ?>
<?php } ?>
and in other part of the code I use again:
<?php while($row = $result->fetch_assoc()) { ?>
html codes.......<?php $row['info'] ?>
<?php } ?>
Is there any way to use same query multiple times to access different columns?
I tested <?php Unset($result) ?> but it does not work.