Ok, I am going to show the entire working script that I am using for my category index page. What I am trying to figure out now (an it's the last thing, I promise) is how to display a dynamic page for ad zone. Let me give you an example of the zone (url) first:
Zone URL:
PHP Code:
$f = fopen('http://reunitemysite.com/scripts/amp/show.php?z=3&incl=1&ip='.getenv('REMOTE_ADDR').'&url='.urlencode(getenv('HTTP_HOST').getenv('REQUEST_URI')),'r');
echo stripslashes(fread($f,100000));
fclose($f);
Now the category index page is:
PHP Code:
<html>
<head><title>Reunite My Site - Category Index</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<meta name="Description" content="The World's Most Trusted Source For Online Advertising!">
<style type="text/css">
html {
height: 100%;
width: 100%;
}
body {
border: 0px solid #000;
height: 100%;
width: 100%;
margin: 0px auto;
font-family: Tahoma, Geneva, sans-serif;
font-size:medium;
color: #000;
}
.gradient {
border: 1px solid #000;
background: #c5deea; /* old browsers */
background: -moz-linear-gradient(top, #c5deea 0%, #8abbd7 31%, #066dab 100%) fixed no-repeat; /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#c5deea), color-stop(31%,#8abbd7), color-stop(100%,#066dab)) fixed; /* webkit */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#c5deea', endColorstr='#066dab',GradientType=0 ); /* ie */
margin: 0px auto;
}
/* Links Section */
a:link {
color:#000;
text-decoration:none
font-family: Tahoma, Geneva, sans-serif;
font-size:medium;
}
a:visited {
color:#000;
text-decoration:none
font-family: Tahoma, Geneva, sans-serif;
font-size:medium;
}
a:hover {
color:#000;
text-decoration:none
font-family: Tahoma, Geneva, sans-serif;
font-size:medium;
}
a:active {
color:#000;
text-decoration:none
font-family: Tahoma, Geneva, sans-serif;
font-size:medium;
}
</style>
<body>
<div class="gradient">
<!-- ------------------------------------------------------------------------------------------------------------------------------------------------------------------->
<!-- C A T E G O R Y I N D E X T E M P L A T E -->
<!-- ------------------------------------------------------------------------------------------------------------------------------------------------------------------->
<?php
// Create Conection To MySQL DB
$db_link = mysql_connect("localhost", "user", "pass");
$db_name = mysql_select_db("db");
// Build Query To Subcategory ID
if ( isset($_GET['id']) && is_numeric($_GET['id'] )) {
$cat_id = $_GET['id'];
$subcats_query_sql = "SELECT * FROM categories, subcategories WHERE categories.category_id = $cat_id AND categories.category_id = subcategories.subcategory_cat_id";
$subcats_query = mysql_query($subcats_query_sql);
// Outputs you a list of subcategories in this category
echo "<div align=\"center\"> <h3> Subcategory Index </h3></div>";
echo "<ul>";
while ($row = mysql_fetch_array($subcats_query) ) echo "<li>{$row['subcategory_name']}";
echo "</ul>";
} else {
echo "<div align=\"center\"> <h3> Category Index </h3></div>";
$cat_query_sql = "SELECT * FROM categories";
$cat_query = mysql_query($cat_query_sql);
$cols=6; // Here we define the number of columns
echo "<div align=\"center\"> <table>"; // The container table with $cols columns
do{
echo "<tr>";
for($i=1;$i<=$cols;$i++) {
// All the rows will have $cols columns even if the records are less than $cols
$row=mysql_fetch_array($cat_query);
if($row){
// $img = $row['image_path'];
?>
<td>
<table>
<tr valign="top">
<!-- <td><img src="http://tycoontalk.freelancer.com/images/<?=$img ?>" /></td> <!-- columns can have both text and images -->
<td>
<!-- This is the categories list in column form -->
<?php echo "<a href=\"categories.php?id={$row['category_id']}\">{$row['category_name']}</a>";?>
<?php $row['email'] ?><br />
<?php $row['password'] ?><br />
</td>
<td width="50"> </td> <!-- Create gap between columns -->
</tr>
</table>
</td>
<?php
}
else{
echo "<td> </td>"; //If there are no more records at the end, add a blank column
}
}
}
while($row);
echo "</table>";
// This is the categories list in list form
//echo "<ul>";
//while ( $row = mysql_fetch_array($cat_query) ) echo "<li><a href=\"categories.php?id={$row['category_id']}\">{$row['category_name']}</a></li>";
//echo "</ul>";
}
?>
</div>
</body>
</html>
:::: NOTE :::: I have progressed some more with this project, but I am still need a push with this next step, or at least another resource online, with a good example of what I am trying to do.
What I would like to have happen is when a category linked is clicked, it shows the subcategories (and yes, all categories WILL contain subcategories) then from the subcategory page, the subcategories will be a linked to a zone url (as I posted in this message, but how??) . Since the above zone (url) code cannot be used in mysql as Chrishirst says, I know I would have to echo out part of the url in the php page, and the other part from mysql, correct? Could someone get me going on that? I feel so stumped, I am naturally good learner by example.
Thank you so much!
-Brian