|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Link Thumbnails
win98, localhost
while ($result = mysql_fetch_array($query)) { $title= $result["title"]; $photo= $result["photo"]; // Using HTML "img" tags for the photos, it selects the photo by it's "id" number echo "$title<br>"; echo ("<img src=\"$photo\" border=0><P><HR width=400 align=left>"); } this shows the thumbnail but how do i link it to the larger pic? if this is not enough code let me know. thanks in advance |
|
#2
|
|||
|
|||
|
PHP Code:
I would do it something like that. The variables are fairly self explanatory. |
|
#3
|
|||
|
|||
|
Quote:
i got the thumbnail to turn into a link, but when i click it simply reloads the page. here is the rest of the code: <?php // Connects to sql server and logs in with username and password // if successful, then the script moves on to displaying the gallery. $connect=mysql_connect("localhost","xxxx","xxx") or die("couldnt connect to sql server"); $db= mysql_select_db("dbname") or die ("couldnt select database"); // Ive set the number of photos per page, in this case I only have 7 photos // so I want to display 1 photo per page. $per_page = 1; // Selects all of the data from database $sql_text = ("SELECT * from photogallery ORDER BY id DESC"); // Sets page number, if no page is specified, it will create page 1 if(!$page) { $page = 1; } $prev_page = $page - 1; $next_page = $page + 1; $query = @mysql_query($sql_text); // Sets up specified page $page_start = ($per_page * $page) - $per_page; $num_rows = @mysql_num_rows($query); if($num_rows <= $per_page) { $num_pages = 1; } else if (($num_rows % $per_page) == 0) { $num_pages = ($num_rows / $per_page); } else { $num_pages = ($num_rows / $per_page) + 1; } $num_pages = (int) $num_pages; if (($page > $num_pages) || ($page < 0)) { error("You have specified an invalid page number"); } $sql_text = $sql_text . " LIMIT $page_start, $per_page"; $query = mysql_query($sql_text); ?> <!-- This starts the web page with HTML and PHP embedded. --> <!-- It also counts how many photos are present in the photo gallery. --> <title>My Photo Gallery</title> <body bgcolor="#ffffff"> <blockquote> There are currently<font color="red"> <?php echo "$num_rows"; ?> </font> photos in My Photo Gallery<p> <!-- It loops through the rows and obtains the data that we created in the table. --> <?php while ($result = mysql_fetch_array($query)) { $title = $result["title"]; $photo = $result["photo"]; $linkToFullPhoto = $result["link2Full"]; // Using HTML "img" tags for the photos, it selects the photo by it's "id" number echo $title.'<br /> <a href="'.$linkToFullPhoto.'"> <img src="'.$photo.'" border="0"> </a><p /> <hr width="400" align="left">'; } // This displays the "Previous" link if ($prev_page) { echo "<a href=\"$PHP_SELF?page=$prev_page\">< Prev</a>"; } // This loops the Pages and displays individual links corresponding // to the photos. for ($i = 1; $i <= $num_pages; $i++) { if ($i != $page) { echo " <a href=$PHP_SELF?page=$i>$i</a>"; } else { echo " $i "; } } // This displays the "Next" link. if ($page != $num_pages) { echo " |<a href=\"$PHP_SELF?page=$next_page\"> Next ></a>" ; } ?> </blockquote> </body> </html> |
|
#4
|
|||
|
|||
|
did you get this to work?
I have a project I'd like to use something like this with, save me time putting all photos in html, ugh! Can I use your code to build the thumbnail page? Do you have a working page yet? Thanks.
__________________
bow wow! |
|
#5
|
|||
|
|||
|
Have you tried to output the values retrieved from the database?
Output the values in $title, $photo, and $linkToFullPhoto... I'm especially curious to see what's in the $linkToFullPhoto. Also, how are you storing the paths to the images in your database?
__________________
____________________________________________ Developer Shed Weekly Writer | DevArticles Forum Moderator Build Your Own KlipFolio Klip With PHP FrankManno.com - Under Construction Design Interactive Group - Under Construction |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Link Thumbnails |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|