i gotta create an image slideshow... only for images.. but all the images should be from the database.. i dont wanna use things apart from html & css... can u help..

Dani AI

Generated

started with a client-side array of filenames and the thread (see , ) headed toward a server-backed solution. A concise, maintainable pattern: have the backend publish the image URLs and let the browser render/animate them. Two practical flows—embed the URLs into the page at render time, or expose an endpoint that returns a JSON list of image paths which the front end fetches.

Example backend endpoint (PHP + PDO) to emit URLs as JSON:

<?php
// images.php
$db = new PDO('mysql:host=localhost;dbname=gallery', 'user', 'pass', [PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION]);
$stmt = $db->prepare('SELECT path FROM images ORDER BY id');
$stmt->execute();
$paths = $stmt->fetchAll(PDO::FETCH_COLUMN);
header('Content-Type: application/json; charset=utf-8');
echo json_encode($paths);

Client-side: fetch that endpoint, populate an <img> or a container, and cycle through the returned array with timed transitions or CSS class toggles. The modern Fetch API is a good fit for this approach (Fetch API docs).

Operational tips and cautions: store image files on disk and save paths in the DB rather than blobs for simpler delivery and caching. Always use prepared statements to avoid injection (PDO prepared statements) and validate/normalize stored paths. Send correct Content-Type and caching headers for performance. For UI patterns, the slider links shared by are useful inspiration for transitions and controls. For security background on injection risks, see OWASP guidance (SQL Injection).

Recommended Answers

All 4 Replies

html cannot connect to a database. you would need to use php, which could be encapsulated within html.

I have used the following codes for the slideshow alongwith a bit more of these....but need some changes.

var photos=new Array()
photos[0]="images/8-x-10-tasveer-5e.jpg"
photos[1]="images/93vande-mataram.jpg"
photos[2]="images/2008_slumdog_millionaire_005.jpg"

now wht i need is that all these images should appear from the database.. i tried doing this with some naive codes but failed.. canu help me with the codes....thax in advance...

You can't do it with just HTML and CSS or Javascript. You'll need PHP to connect to your database.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.