You are here: Re: Problems outputting to a 3 column table in order to crate an image gallery « PHP Programming Language « IT news, forums, messages
Re: Problems outputting to a 3 column table in order to crate an image gallery

Posted by ste on 11/19/31 11:46

"Rik" <luiheidsgoeroe@hotmail.com> wrote in message
news:e329sc$r4j$1@netlx020.civ.utwente.nl...
> Rik wrote:
>> $where = (isset($_GET['imagetype'])) ? "WHERE imagetype =
> '".$_GET['imagetype']."'" : '';
>
> Should be:
> $where = (isset($_GET['imagetype'])) ? "WHERE imagetype =
> '".$imagetype."'"
> : '';
> --
> Rik Wasmus


Thanks for this Rik. If I'm understanding this correctly, adding the above
code to the existing gallery script will allow all images in the database to
be displayed when a user opens the gallery.php (as it was currently
displaying a blank page), or, it can still be used to open specific
galleries when it is used with the extension of
gallery.php?imagetype=landscape

I have added your code to the existing code, and also removed the previous
line of code which contained the old $query line.

Unfortunately (and I've probably done something wrong here), the code below
(which is how I've incorporated your latest piece of code into the existing
code) doesn't quite do this - when I open gallery.php, it's not opening all
the images, but is instead opening all images which have a blank value for
imagetype (which would normally be none, but I've just added an image to the
database to test, which is why I know this is what's happening). When I
open gallery.php?imagetype=landscape, this works as it did previously so no
problems here. Have I added it correctly?

<?php
include("my_db_login.inc");

$connection = mysql_connect($host,$user,$password) or die ("couldn't connect
to server");
$db = mysql_select_db($database,$connection) or die ("Couldn't select
database");

if(get_magic_quotes_gpc()){
$_GET['imagetype'] = stripslashes($_GET['imagetype']);
}

$imagetype = mysql_real_escape_string( $_GET['imagetype'], $connection);
$where = (isset($_GET['imagetype'])) ? "WHERE imagetype = '".$imagetype."'":
'';
$query = "SELECT * FROM mydatabase ".$where;
$result = mysql_query($query) or die ("Couldn't execute query.");

echo "\n<div id=\"content\">";
echo "\n<h2>Sample Gallery</h2>";
echo "\n<table id=\"thumbgallery\" cellSpacing=\"0\" cellPadding=\"10\"
width=\"400\" border=\"0\">";
echo "\n<tbody>";
$i = 3;
while ($row = mysql_fetch_assoc($result))
{
if($i==3) echo "\n\t<tr>";
echo "\n\t\t<td valign=\"top\" width=\"113\" id=\"thumbs\"><img
src=\"".$row['imagelocation']."\" width=\"113\" border=\"0\" /><p
class=\"captionref\">Ref: ".$row['imageid']."</p><p
class=\"caption\">".$row['imagecaption']."</p></td>";
$i--;
if($i==0) {
echo "\n\t<tr>";
$i = 3;
}
}
if($i!=3) echo "\n\t\t<td colspan=\"$i\"></td>\n\t</tr>";
echo "\n</tbody>";
echo "\n</table>";

?>


Thanks,

Ste

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация