Forum Moderators: coopster & phranque

Message Too Old, No Replies

Search Pages

Only that instead of links it pictures (.jpg)

         

circuitjump

6:12 am on Nov 26, 2001 (gmt 0)

10+ Year Member



Hi all,
Hope everyone in the US had a Happy Thanksgiving and everyone else had a good weekend.

Well, here is what I need. I am making an application that lets you upload pics to a server and also adds the directory to a DB. Now I just need to display the pics and I want to do it a page a picture. Kinda like a search page. AV or Google style. But instead of a link its a pic and then you can choose to go to the next one by clicking on a link. But the whole time it's one dynamic page pulling info off of a mySQL database.

Thanks all

sugarkane

6:48 pm on Nov 26, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Quickest/easiest way I can think of is to throw all the results into an array and build an offset into your links. Say you had an array of file names in @images, your code would be something like

[perl]
if ($offset) { # check if there's an offset defined
print "<img src=\"$images[$offset]\">; # if so use it
}
else {
print "<img src=\"$images[0]\">; # if not, show the first element
}

# Now increment $offset and build a link with it
$offset++;
print "<a href=\"showimage.cgi?offset=$offset\">Next image</a>";
[/perl]

That would be the basic idea - of course you could get fancy and build a 'previous image' link if $offset > 1, only show the 'next' link if $offset is less than the number of elements in @images, etc

circuitjump

10:35 pm on Nov 26, 2001 (gmt 0)

10+ Year Member



Thanks! :)

circuitjump

10:11 pm on Nov 29, 2001 (gmt 0)

10+ Year Member



I can't seem to get it to go to the next pic.

Here is the code


<?php
// Include connection
include ("connect.php");
$title = $HTTP_GET_VARS['title'];
// SQL Query
$sql_insert = "select * from ind_homes_pics where title='".$title."'";
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#336699">
<?php
$grab_info = mysql_query( $sql_insert );
while ($db_get = mysql_fetch_object ($grab_info))
{
$offset = ($db_get->pic_dir);
$description = ($db_get->discription);
}
?>
<table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td align="center" bgcolor>
<? print $description; ?>
</td>
</tr>
<tr>
<td align="center">
<?php
if ($offset) { # check if there's an offset defined
print "<img src=$offset>"; # if so use it
}
else {
print "<img src=$offset>"; # if not, show the first element
}
?>
</td></tr>
<?php
$offset++;
# Now increment $offset and build a link with it
if (!empty($offset)) {
print "<tr><td align=center bgcolor=#CCCCCC><font size=2 face=Arial><a href=pictures.php?offset=$offset>Next image</a></font></td></tr>";
}
mysql_close( $link );
?>
</table>
</center>
</body>
</html>

Please Help :)

Also here is a link to the page
TEST PAGE [imageworksstudio.com]

circuitjump

9:58 pm on Dec 2, 2001 (gmt 0)

10+ Year Member



Got it working! :)

Thanks