I've tried getting help from several other forums, and nobody seemed to know what they were talking about. I'm sure someone here at PHP Builder will know.
Okay, I've encountered a new problem with a subcategory system in my photo gallery app. The thing seems to be working... it returns the correct amount of rows from the database, but won't format it when using the 'while' loop.
The script should get rows in the database that have the gallery that matches GET information. Then, it checks to see if there is a subcategory, or in this case it's labeled landing. If there is a landing, it adds a 1 to a counter variable. After it checks every row, the program either displays a list of links to the subcategories or redirects to a main gallery.
Here's my problem: If rows are returned, the formatting around where the list of links should go are there, but the links simply won't show up. It's almost like the array I created earlier in the program isn't there.
If anyone can see why this isn't working, I'd really appreciate it! 🙂
<?php
$gallery = strip_tags($_GET['gallery']);
$dbhost = "*****";
$dbuser = "*****";
$dbpass = "*****";
$db = "siteinfo";
$connect = mysql_connect($dbhost,$dbuser,$dbpass)
or die(mysql_error());
$selectdb = mysql_select_db($db,$connect)
or die(mysql_error());
$query = "SELECT id,landing,landing_id FROM photographs WHERE gallery = '$gallery'";
$result = mysql_query($query);
$countervar = "0";
while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
extract($row);
if(isset($landing))
{
if($landing != "")
{
$countervar = $countervar + 1;
$land = $landing;
}
}
}
if($countervar >= "1")
{
session_start();
include("/files/includes/headerinclude.php");
echo "<body>";
echo "<table border='0' cellspacing='1' cellpadding='1' width='700' align='center'>";
echo "<tr>";
echo "<td colspan='2' valign='bottom' align='left'>";
include("/files/includes/topimageinclude.php");
echo "</td>";
echo "</tr>";
echo "<tr>
<td valign='bottom' align='left' colspan='2'>";
include("/files/includes/navbarinclude.php");
echo "</td></tr>";
echo "<tr>";
echo "<td width='100' valign='top' align='left'>";
include("/files/includes/sidebarinclude.php");
echo "</td>";
echo "<td width='600' valign='top' align='left'>";
echo "<table width='600' border='0' cellspacing='1' cellpadding='1'>";
while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
extract($row);
echo "<tr><td><div id='normal'><a href='/galleries/showGallery.php?gallery={$gallery}&landing={$landing_id}</a></div></td></tr>";
}
echo "</table>";
echo "</td>";
echo "</tr></table>";
include("/files/includes/footerinclude.php");
echo "</body>";
echo "</html>";
}
else
{
header("Location:/galleries/showGallery.php?gallery={$gallery}");
}
?>