General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 9th, 2002, 02:43 PM
DivaX007 DivaX007 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 23 DivaX007 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old December 9th, 2002, 03:39 PM
Kanu Kanu is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 91 Kanu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
PHP Code:
while ($result mysql_fetch_array($query)) {
echo <<<imagetemplate
<p class="yourstyle">$result["title"]</p>
<a href="$result
["bigphoto"]"><img src="$result["photo"] border=0><P><HR width=400 align=left></a>
imagetemplate; 


I would do it something like that. The variables are fairly self explanatory.

Reply With Quote
  #3  
Old December 9th, 2002, 04:34 PM
DivaX007 DivaX007 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 23 DivaX007 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally posted by Kanu
PHP Code:
while ($result mysql_fetch_array($query)) {
echo <<<imagetemplate
<p class="yourstyle">$result["title"]</p>
<a href="$result
["bigphoto"]"><img src="$result["photo"] border=0><P><HR width=400 align=left></a>
imagetemplate; 


I would do it something like that. The variables are fairly self explanatory.



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>

Reply With Quote
  #4  
Old December 11th, 2002, 07:46 PM
littleblackdog littleblackdog is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Anchorage
Posts: 118 littleblackdog User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
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!

Reply With Quote
  #5  
Old December 11th, 2002, 10:07 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Link Thumbnails


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT