Forum Moderators: coopster

Message Too Old, No Replies

PHP script from thumbnail page jump to more detail page

         

bubble

11:11 am on Jun 9, 2008 (gmt 0)

10+ Year Member



I am do a website that required to display item thumbnails as links in a page(CSS divs), when visitor click on the a thumbnail, it will bring up a page shows a bigger image(smae item) and description.

I need to do this use PHP, I have a MySql database table with fields: code, thumbnail, big image, description, status.

First question is How can I display thumbnails in DIVs loop in horizantal way.

2nd question is how to script the PHP page that brings a page showing the cliked item's bigger image and description.

I am new to PHP help please!

PHP_Chimp

4:00 pm on Jun 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The answer to your first question is a CSS answer.
You could inline your div's, you could absolute position the divs's or use a combination of other techniques.
Ask the CSS people.

For the page with the larger pic on:


// get info from database
$out = '';
while ($row = [url=http://uk2.php.net/manual/en/function.mysql-fetch-array.php]mysql_fetch_array[/url]($result)) {
$out.= "<div class='mini_pic' id='{$row['code']}'>";
$out.= 'This is some picture...miniaturized.';
$out.= "<img src='{$row['thumbnail']}' height='200' width='200' />";
$out.= "<a href='page?big_image={$row['code']}'>";
$out.= 'Click here for a larger image</a>';
$out.= '</div>';
}
mysql_free_results($result);
echo $out;

So this (should, hopefully) give you a div with the code for the picture (in case you want to supply specific CSS to a specific pic), a general class (so you can CSS all of the mini_pic's). Some text and the thumb image. Then a link to another page (cunningly named page) that takes the $_GET['big_image'] variable and uses that to get the correct image from the database.
I have assumed that the code from the database is the primary key for the table, so lookups based on that will be faster than look ups based on other fields (unless you have other indexes running).

See you how get on with the code and come back if you get any errors.