View Full Version : Need some help on this, please!
Dark_Wizard
08-08-2002, 08:53 AM
I am writing a Gallery script using vbulletins templates and want to list the pics in rows of 3 across. Here is a snippet of my code but everything I tried didn't work.
<?php
require("./global.php");
$result = $DB_site->query("SELECT * FROM photos WHERE albumid=$album");
while($row = $DB_site->fetch_array($result))
{
$picid = $row["picid"];
$url = $row["url"];
$title = $row["title"];
$counter = 0;
$x = 0;
$x++;
eval("\$gallerybits .= \"".gettemplate("gallery_bits")."\";");
if($x == 3)
{
echo "</tr><tr>";
$x = 0;
}
$counter++;
}
eval("dooutput(\"".gettemplate("gallery")."\");");
?>
as you can see it isn't complete. Any help would be appreciated.
Here is the gallery_bits template:
<td>
<normalfont><a href=photo.php?id=$picid><img width="150" border="0" height="150" src="photos/$url" alt="$title"></a>
<br><center>$title</center></normalfont>
</td>
Dark_Wizard
08-09-2002, 12:20 PM
^Bump^
I've updated it above with what I have right now.
Lesane
08-13-2002, 01:10 PM
Try this:
<?php
require("./global.php");
$result = $DB_site->query("SELECT * FROM photos WHERE albumid=$album");
$counter = 0;
while($row = $DB_site->fetch_array($result))
{
$picid = $row["picid"];
$url = $row["url"];
$title = $row["title"];
if ($counter%3=="2") {
echo "</tr><tr>";
}
eval("\$gallerybits .= \"".gettemplate("gallery_bits")."\";");
$counter++;
}
eval("dooutput(\"".gettemplate("gallery")."\");");
?>
Dark_Wizard
08-13-2002, 07:29 PM
Thx...I'll give it a shot. Thx for the response! :)
Dark_Wizard
08-13-2002, 10:04 PM
It works on the first row but every subsequent row there is only 1 pic.... click here (http://www.islandncs.com/gw/forums/gallery.php?album=2)
Lesane
08-14-2002, 08:49 AM
Play with this line:
if ($counter%3=="2") {
set 2 to 0.
Dark_Wizard
08-14-2002, 11:26 AM
I got it to work but my problem is with the templates and displaying the pics properly...I can't wait till vb3 where we can use conditionals in the templates....
Dark_Wizard
08-14-2002, 11:57 AM
Here is the code I am now using and it works except I can't get it to work with the templates....
<?php
require("./global.php");
$result1 = $DB_site->query("SELECT * FROM albums WHERE id=$album");
$res = $DB_site->fetch_array($result1);
$event = $res["title"];
$result = $DB_site->query("SELECT * FROM photos WHERE albumid=$album");
$i = 0;
echo "<table>\n<tr>\n";
while ($row = mysql_fetch_assoc($result))
{
$picid = $row["picid"];
$url = $row["url"];
$title = $row["title"];
if (($i++ % 3) == 0) {
echo "</tr>\n<tr>\n";
}
echo "<td><normalfont><a href=photo.php?id=" . $row['picid'] . "><img width=\"150\" border=\"0\" height=\"150\" src=\"photos/" . $row['url'] . "\" alt=" . $row['title'] . "></a><br><center>" . $row['title'] . "</center></normalfont></td>\n";
}
echo "</tr>\n</table>\n";
eval("dooutput(\"".gettemplate("gallery")."\");");
?>
Any ideas? Here is the gallery template:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>$bbtitle Photo Album</title>
$headinclude
</head>
<body>
$header
<table cellpadding="0" cellspacing="0" border="0" width="95%" align="center"><tr><td>
<table cellpadding="2" width="100%">
<tr bgcolor="#336D95" background="https://vborg.vbsupport.ru/images/catagory_backing.gif">
<td width="100%" align="center" height="28">
<H3>$bbtitle Photo Album</H3>
</td>
</tr>
<tr>
<td>
<table border="0" cellspacing="1" cellpadding="3"width="100%" align="center">
$gallerybits
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
$footer
</body>
</html>
And the gallery_bits template:
<td><normalfont><a href=photo.php?id=$picid><img width="150" border="0" height="150" src="photos/$url" alt="$title"></a><br><center>$title</center></normalfont></td>
Lesane
08-14-2002, 12:17 PM
You are saying in the code (without the template) this:
echo "<table>\n<tr>\n";
The code with the template you say:
<table border="0" cellspacing="1" cellpadding="3"width="100%" align="center">
$gallerybits
</table>
No <tr> in the code with the template ;)
Dark_Wizard
08-14-2002, 12:41 PM
The <tr> is there in the line:
echo "<table>\n<tr>\n";
Dark_Wizard
08-14-2002, 12:43 PM
Here is the code with the gallery_bits template and it now just displays everything in one line...
<?php
require("./global.php");
$result1 = $DB_site->query("SELECT * FROM albums WHERE id=$album");
$res = $DB_site->fetch_array($result1);
$event = $res["title"];
$result = $DB_site->query("SELECT * FROM photos WHERE albumid=$album");
/*
$i = 0;
echo "<table>\n<tr>\n";
while ($row = mysql_fetch_assoc($result))
{
$picid = $row["picid"];
$url = $row["url"];
$title = $row["title"];
if (($i++ % 3) == 0) {
echo "</tr>\n<tr>\n";
}
echo "<td><normalfont><a href=photo.php?id=" . $row['picid'] . "><img width=\"150\" border=\"0\" height=\"150\" src=\"photos/" . $row['url'] . "\" alt=" . $row['title'] . "></a><br><center>" . $row['title'] . "</center></normalfont></td>\n";
}
echo "</tr>\n</table>\n";
*/
$i = 0;
echo "<table>\n<tr>\n";
while ($row = mysql_fetch_assoc($result))
{
$picid = $row["picid"];
$url = $row["url"];
$title = $row["title"];
if (($i++ % 3) == 0) {
echo "</tr>\n<tr>\n";
}
eval("\$gallerybits .= \"".gettemplate("gallery_bits")."\";");
}
echo "</tr>\n</table>\n";
eval("dooutput(\"".gettemplate("gallery")."\");");
?>
Lesane
08-14-2002, 01:21 PM
Originally posted by Dark_Wizard
The <tr> is there in the line:
echo "<table>\n<tr>\n";
I know, there is a <tr> in your "Non Template" code.
But, you are missing that <tr> in the "template code".
This code from your gallery template:
<table border="0" cellspacing="1" cellpadding="3"width="100%" align="center">
$gallerybits
</table>
Should look like this:
<table border="0" cellspacing="1" cellpadding="3"width="100%" align="center">
<tr>
$gallerybits
</table>
Dark_Wizard
08-14-2002, 01:57 PM
Added it and still the same thing...
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.