Forum Moderators: coopster

Message Too Old, No Replies

connecting photos to links in a gallery

         

Helix

7:57 pm on May 6, 2011 (gmt 0)

10+ Year Member



OK. I have this gallery where people upload photos and they display on a page where they become links. Now what I want to do is add my comment system to each photo so when someone clicks on a photo a new page opens with the enlarged image and comments. Right now the links go nowhere. Supposed to go to the main photo but don't. Also I'm not sure how to keep the comments specific to the photo so they don't post on all the photos. I'm guessing it's an id thing. I'm using dreamweavers server behaviors just beacuse. If that affects anything please let me know.

Thanks in advance. I could really use the help. Still new to PHP but getting there...I hope.



<?php require_once('myconn.php');

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$maxRows_Recordset1 = 40;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

mysql_select_db($database_myconn, $myconn);
$query_Recordset1 = "SELECT name, photopath, `state` FROM photo";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $myconn) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?>

<div id="photos">
<table border="">
<?php $i=0; $numperpage=8; ?>
<?php do { ?>
<?php if ($i%$numperpage==0) echo "<tr>"; ?>
<td align="center">
<a href=<?php echo $row_Recordset1['photopath']; ?>/>
<img src=<?php echo $row_Recordset1['photopath']; ?> height="200" width="200"/>

<br/>

<?php echo $row_Recordset1['name']; ?><br/> <?php echo $row_Recordset1['state']; ?></td>
<?php $i++; if ($i%$numperpage==0) echo "</tr>"; ?>



<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
</div>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

coopster

2:10 pm on May 24, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, Helix.

The href attribute of your anchor element is pointing to the photo image. If you want a new page to be displayed you will need to create a server-side processing script in PHP that accepts the identifier of the photo so you can pull the full size image and the comments from your database table for that particular photo identifier.