Here's a rough link of listings - click a listing, see the anchored image - except it doesn't.
Here's my code for the listings page
And here's the category page stuff
I'd like to get this part going so I can get working on the styling, but this is baffling me.
What do I need to change?
Thanks,
Donna
Here's my code for the listings page
Code:
<?php
//CREATE THE SQL QUERY TO PULL ALL VISIBLE LISTINGS
$sql = "select * from advertisers a left join category c USING(category_id) ";
$sql .= "WHERE a.visible = 1 order by c.category_name asc, a.advertiser_name asc ";
$result = mysql_query($sql);
$currentCategory = "";
while($row = mysql_fetch_array($result)){
//PRINT OUT THE CATEGORY NAME EVERY TIME IT CHANGES
if($currentCategory == "" || $currentCategory != $row['category_id']){
echo "<div class='categoryName' style='font-weight:bold;margin-top:8px;'>";
echo "<a href='category.php?cid=".$row['category_id']."'>" .stripslashes($row['category_name'])."</a></div>";
$currentCategory = $row['category_id'];
}
//PRINT OUT THE ADVERTISER
echo "<div class='advertiserName'>";
echo "<a href='category.php?cid=".$row['category_id']."#advertiser_".$row['advertiser_id']."'>";
echo stripslashes($row['advertiser_name']);
echo "</a></div>";
}
?>
And here's the category page stuff
Code:
<?php
//make sure there is a valid category id passed
$found = false;
$category = array();
$catSql = "select * from category where category_id = '".$_GET['cid']."'";
$result = mysql_query($catSql);
if(mysql_num_rows($result) > 0){
$found = true;
$category = mysql_fetch_array($result);
}
if($found){
$sql = "select * from advertisers a left join category c using(category_id) WHERE ";
$sql .= " c.category_id = '".$_GET['cid'] . "' and a.visible = 1 order by a.advertiser_name asc ";
$result = @mysql_query($sql);
//PRINT OUT THE CATEGORY TITLE
echo "<h1>".stripslashes($category['category_name'])."</h1>";
//LOOP THROUGH THE RESULT SET AND PRINT OUT THE IMAGES
while($row = mysql_fetch_array($result)){
//PUT EACH ADVERTISER IN A SEPARATE DIV THAT CAN BE USED FOR STYLING
echo "<div>";
//PRINT OUT THE ANCHOR FOR THE RECORD
echo "<a name='product_".$row['product_id']."' />\n";
//PRINT OUT THE FIRST IMAGE IF IT EXISTS
if(trim($row['img1']) != "" && file_exists($row['img1']))
echo "<img src='".$row['img1']."' alt=\"".stripslashes($row['advertiser_name'])."\"/>";
echo "<br>";
echo "<a href='listings.php'>Back to Listings</a>";
echo "<br>";
//A SECOND IMAGE EXISTS. SPIT OUT A BREAK AND DISPLAY THE IMAGE
if(trim($row['img2']) != "" && file_exists($row['img2'])){
echo "<br>";
echo "<img src='".$row['img2']."' alt=\"".stripslashes($row['advertiser_name'])."\"/>";
echo "<br>";
}
echo "</div>";
}
}
else{
//put an error message here
?>
you screwed up - please try again
<?
}
?>
I'd like to get this part going so I can get working on the styling, but this is baffling me.
What do I need to change?
Thanks,
Donna