Buongiorno con questo codice non vedo le immagini e mi da errore:
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\prove\imgdb\ProvaPaginazione.php on line 34
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\prove\imgdb\ProvaPaginazione.php on line 34
PHP:
<!DOCTYPE html>
<head>
<title>Pag</title>
</head>
<body>
<?php
// connect to database
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "foto";
// Create connection
$con = mysqli_connect($servername, $username, $password, $dbname);
// define how many results you want per page
$results_per_page = 10;
// find out the number of results stored in database
$sql= 'SELECT id, image FROM images';
$result = mysqli_query($con, $sql);
$number_of_results = mysqli_num_rows($result);
// determine number of total pages available
$number_of_pages = ceil($number_of_results/$results_per_page);
// determine which page number visitor is currently on
if (!isset($_GET['page'])) {
$page = 1;
} else {
$page = $_GET['page'];
}
// determine the sql LIMIT starting number for the results on the displaying page
$this_page_first_result = ($page-1)*$results_per_page;
// retrieve selected results from database and display them on page
$sql="SELECT id, image FROM images LIMIT ";
$result = mysqli_query($con, $sql);
while($row = mysqli_fetch_array($result)) {
echo '<img src="data:image/jpeg;base64,'.base64_encode($row['image'] ).'" height="200" width="200"/>';
}
// display the links to the pages
for ($page=1; $page<=$number_of_pages; $page++) {
echo '<a href="index.php?page=' . $page . '">' . $page . '</a> ';
}
?>
</body>
</html>
Ultima modifica di un moderatore: