Im not sure if this is a php problem or javascript, but since the actual photo gallery is run by javascript I'll post it here, sorry if its not though.

Everything works fine but when I click on another image to change the main image the caption wont change with it.

<script type="text/javascript">
// Gallery script.
// With image cross fade effect for those browsers that support it.
// Script copyright (C) 2004-08 [url]www.cryer.co.uk[/url].
// Script is free to use provided this copyright header is included.function LoadGallery(pictureName,imageFile,titleCaption,captionText)
function LoadGallery(pictureName,imageFile)
{
	var picture = document.getElementById(pictureName);
	if (picture.filters)
	{
		picture.style.filter="blendTrans(duration=1)";
		picture.filters.blendTrans.Apply();
	}
	picture.src = imageFile;
	if (picture.filters)
	{
		picture.filters.blendTrans.Play();
	}
	document.getElementById(titleCaption).innerHTML=captionText;
}
            </script>
            <?

$con = mysql_connect('','','') or die('Error: ' . mysql_error());
mysql_select_db('') or die('Error: ' . mysql_error());

$colNum = 1;

$sql = "SELECT * FROM `` ORDER BY `id` DESC LIMIT 0, 1";
$query = mysql_query($sql,$con) or die('Error: ' . mysql_error());
$table = '<table align="center" border="0" width="20px" cellpadding="0" cellspacing="0">';
$table .= '<tr>';
$num = 1;
while ($r = mysql_fetch_array($query)) {
	$id=$r['id'];
	$name=$r['name'];
	$image=$r['image'];
	$caption=$r['caption'];
$table .=<<<HTML
<td>
<table border=0 width=20px cellpadding=2 cellspacing=0>
	<tr>
		<td align=center>
			<img src=$image height=400px alt=$name id=showreel>
			<div id="showcaption">$caption</div>
		</td>
	</tr>
</table>
</td>
HTML;
	if ($num == $colNum) {
		$table .= '</tr><tr>';
		$num = 0;
	}
$num++;
}
$table .= '</table>';

echo $table;

mysql_close($con);

?>
            </p>
                    
                    <p class="century-gothic"><?

$con = mysql_connect('','','') or die('Error: ' . mysql_error());
mysql_select_db('') or die('Error: ' . mysql_error());

$colNum = 12;

$sql = "SELECT * FROM `` ORDER BY `id` DESC LIMIT 0, 100";
$query = mysql_query($sql,$con) or die('Error: ' . mysql_error());
$table = '<table align="center" border="0" width="20px" cellpadding="0" cellspacing="0">';
$table .= '<tr>';
$num = 1;
while ($r = mysql_fetch_array($query)) {
	$id=$r['id'];
	$name=$r['name'];
	$image=$r['image'];
	$caption=$r['caption'];
$table .=<<<HTML
<td>
<table border=0 width=20px cellpadding=2 cellspacing=0>
	<tr>
		<td align=center>
			<a href="#_self" onclick="LoadGallery('showreel','$image','showcaption','$caption')"><img src=$image height=30px alt=$name></a>
		</td>
	</tr>
</table>
</td>
HTML;
	if ($num == $colNum) {
		$table .= '</tr><tr>';
		$num = 0;
	}
$num++;
}
$table .= '</table>';

echo $table;

mysql_close($con);

?>

The website Page: http://collmillsg.com/showreel.php

Recommended Answers

All 2 Replies

Hi there,

At first glance I notice the original function is function LoadGallery(pictureName,imageFile,titleCaption,captionText) while yours is function LoadGallery(pictureName,imageFile) . Yet on line 88 you call the LoadGallery function with 4 parameters <a href="#_self" onclick="LoadGallery('showreel','$image','showcaption','$caption')"> .

The JavaScript errors you keep getting on your site do mention the lack of a 'titleCaption' variable so perhaps it's a quick fix.

Again, try replacing

function LoadGallery(pictureName,imageFile)

with

function LoadGallery(pictureName,imageFile,titleCaption,captionText)

Hope that helps.

Good luck,

Traevel

Hey thanks, yeah that was it. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.