thumbnails on a webpage

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
PaveFE
Forum Newbie
Posts: 3
Joined: Tue Apr 07, 2009 4:20 pm

thumbnails on a webpage

Post by PaveFE »

Hello,
I'm developing a web page that is a php query result from a form that my users submit. It's pretty much a contact list. I have it set up so that users fill out a form with some contact info, background info, comments, and a photo. After they submit their info, they can click on the contact list page to see the list of people who signed up so far. This just has some basic info and then a link for another page for extended information about the person that the user selected. What I'm looking for is on the first page with the basic info, I want to show a thumbnail sized photo of each person from the photo they submitted and is stored in the database. Right now, the actual photo submitted is the one that shows up. I'm very new to all this and have had some help building it thus far, hence the reason I'm here now.

Here's my code for the first page:
<?php
// Make a MySQL Connection and pick the example database "contactsdb"
mysql_connect("localhost", "user", "password") or die(mysql_error());
mysql_select_db("my_database") or die(mysql_error());

// Get the data from your table, in this example..the "contacts" table..since you want certain data..we'll use example columns "name" and "phone"

$result = mysql_query("SELECT hdw_id, Name, Address, City, State, Zip, Phone1, email, Background, Photo FROM members ORDER BY Name ")
or die(mysql_error());

echo "<table border='0' cellpadding='0' cellspacing='0' align='left' width='100%' class='clist_table'>";
echo "<tr> <th class='clist_table_hdg'>Name</th> <th class='clist_table_hdg'>Address</th> <th class='clist_table_hdg'>Phone</th> <th class='clist_table_hdg'>Email</th> <th class='clist_table_hdg'>Background</th> <th class='clist_table_hdg'>MoreInfo</th> <th class='clist_table_hdg'>Photo</th> </tr>";
//get the data from the rows
while($row = mysql_fetch_array( $result )) {
$id = $row['hdw_id'];
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['Name'];
echo "</td><td nowrap='nowrap'>";
echo $row['Address'];
echo "<br />";
echo $row['City'];
echo "<br />";
echo $row['State'];
echo ", ";
echo $row['Zip'];
echo "</td><td>";
echo $row['Phone1'];
echo "</td><td><a href='mailto: ";
echo $row['email'];
echo "'>Email";
echo "</a></td><td>";
echo $row['Background'];
echo "</td><td><a href='community_contact_list_extended.php?id=$id'>MoreInfo</a></td><td>";
echo "<img src='";
echo $row['Photo'];
echo "'></td><tr>";
}

echo "</table>";
?>
Thanks in advance for your help.

Vince
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: thumbnails on a webpage

Post by Christopher »

To make a thumbnail from the full size image you will need to use the GD or ImageMagick libraries. Check if one is installed using phpinfo().
(#10850)
PaveFE
Forum Newbie
Posts: 3
Joined: Tue Apr 07, 2009 4:20 pm

Re: thumbnails on a webpage

Post by PaveFE »

My web host has both.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: thumbnails on a webpage

Post by Christopher »

Check the manual or use a library like this http://phpgd.com/. I recall that just resizing is pretty easy.
(#10850)
PaveFE
Forum Newbie
Posts: 3
Joined: Tue Apr 07, 2009 4:20 pm

Re: thumbnails on a webpage

Post by PaveFE »

I don't have the time to read through and figure it out myself. I was hoping someone could just show me the code that I need to put in there, which I'm sure is easy for most of those who do know. I posted what I had so far and what I needed. Is this not possible?

Thanks,

Vince
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: thumbnails on a webpage

Post by Christopher »

There are examples in the manual. The functions that have to do with making a copy of an image are used to do resizing as I recall.
(#10850)
Post Reply