Hello,
I am currently designing a site that displays photography, and am exploring the different ways in which to do this.
I am trying to develop, using PHP and MYSQL, a way of having image links held in a database and then the first image in sequence to be rendered by the browser, and underneath previous and next links to cycle through the images.
Each table will only hold at a maximum 30 image links.
I'm sure that this is relatively easy to do, (I am a complete programming novice) I know enough to link to the database and display an image in the browser but cannot figure how the hell to create the previous / next links that call to the database.
PLEASE HELP!!!
<?php
$username = 'xxxx';
$password = 'xxxx';
$link = mysql_connect('localhost', $username, $password);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('dataBase', $link);
$result = mysql_query('SELECT * FROM images ORDER BY title LIMIT 1;');
if (!$result) {
die('Could not query:' . mysql_error());
}
while ($row = mysql_fetch_object($result)) {
echo '<img src="'. $row->path.'" alt="'. $row->title .'" title="'. $row->id.'" />'; // print out image
////below is my, er, attempt...
///$prev = $row - 1;
///next = $row + 1;
///echo '<a href="'. $prev->path.'" alt="'. $prev->title .'" title="'. $prev->id.'">previous</a>';
///echo '<a href="'. $next->path.'" alt="'. $next->title .'" title="'. $next->id.'">next</a>';
}
mysql_close($link);
?>