lundi 12 janvier 2015

Basic gallery with PHP JavaScript and MySQL


I want to create a page which shows e.g. 10 pictures/posts and when you click the next button the next 10 pictures/posts should be added to the page. So when the page loads it should display 10 pictures/posts when you click "next" then the pages shows 20 pictures/posts and so on.


Until now I store the pictures in a folder and their filenames are stored in a table of my database. The posts are also stored in a table of my database.


So I select all posts and picture names from my database and then I create an array with them.


Next I display every row of the array with a while loop.


So what should I do to reach my goal which I described at the start preferably using PHP, HTML, CSS, MySQL, JavaScript?



$res = mysqli_query($conn, "SELECT * FROM entries INNER JOIN users ON entries.userid=users.userid ORDER BY date DESC");

while($dsatz = mysqli_fetch_assoc($res))
{
$id = $dsatz["entriesid"];
$title = $dsatz["title"];
$title = str_replace("\n","<br>",$title);
$entry = $dsatz["entry"];
$entry = str_replace("\n","<br>",$entry);
$date = $dsatz["date"];
$picture = $dsatz["picture"];
$user = $dsatz["name"];
$user = str_replace("\n","<br>",$user);

echo "\n\n<div id='post'>"
. "<h4>$title</h4>"
. "<div>$entry</div><br />"
. "<div><img src='$picture' alt=''/></div>"
. "<div>Author: $user</p></div>"
. "<div><em>" . date("$date") . "</em></div>"
. "</div>";
}




Aucun commentaire:

Enregistrer un commentaire