<?php
include "Template_Header.php";
//Getting the file db.php which includes our database settings.
define( 'DB_PATH' , "./" );
require DB_PATH."db.php";
//Setting up a variable to request the category which is in the URL
$request_cat = $_REQUEST['category'];
//Displaying an actual tutorial
if (isset($id)) {
// Updating the views, and grabbing a tutorial based on what id it has.
$update = mysql_query("UPDATE $mysql_table SET views = views + 1
WHERE id='$id'");
$result = mysql_query("SELECT * FROM $mysql_table
WHERE id='$id'");
while($row = mysql_fetch_array($result)){
// Template for the tutorial
echo "
<table width='400' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='400'>
<table width='400' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td><table width='400' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='275'><div align='left'><strong>
<a href='tutorials.php?category=".$row['category']."&id=".$row['id']."
'>".$row['title']."</a>
</strong></div></td>
<td width='125'><div align='right'>
[ Views: ".$row['views']." ]</div></td>
</tr>
</table></td>
</tr>
<tr>
<td><div align='left'>Description: ".$row['description']."</div></td>
</tr>
<tr>
<td><div align='left'>".$row['content']."</div></td>
</tr>
<tr>
<td><div align='left'>
<table width='400' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='150'><div align='left'>Added: ".$row['date']."</div>
</td>
<td><div align='right'>Author:
<a href='mailto:".$row['email']."'
>".$row['author']."</a> </div></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td><div align='left'>Category:
<a href='tutorials.php?category=".$row['category']."
>".$row['category']."</a> </div></td>
</tr>
</table></td>
</tr>
</table>
"; // End of template of tutorial
} // End of grabbing data
// Stopping anything below from interfearing with this sectiom
} // End of Displaying an actual tutorial
//Displaying tutorials in a cateogry.
else if ($category == $request_cat) {
//Grabbing information from the database.
$result = mysql_query("SELECT * from $mysql_table
where category = '$category' ORDER BY ID DESC");
while($row = mysql_fetch_array($result)) {
//Template for the tutorials in a category.
echo "
<table width='400' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='100' align='center' valign='middle'><div align='center'>
<a href='tutorials.php?category=".$row['category']."&id=".$row['id']."'>
<img src='".$row['avatar']."' alt='".$row['title']."' title='".$row['title']."'
width='90' height='60' border='0'></a>
</div></td>
<td width='300'>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td>
<div align='center'><strong>".$row['title']."</strong></div></td>
</tr>
<tr>
<td>
<div align='left'>Description: ".$row['description']."</div></td>
</tr>
<tr>
<td>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td><div align='left'>Added: ".$row['date']."</div></td>
<td><div align='left'>Category:
<a href='tutorials.php?category=".$row['category']."
>".$row['category']."</a></div></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='175'><div align='left'>Author:
<a href='mailto:".$row['email']."'>".$row['author']."</a></div></td>
<td width='100'><div align='left'>Views: ".$row['views']."</div></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table><br>
"; // End of Template for the tutorials in a category.
} // End of grabbing information from database.
} // End of Displaying tutorials in a cateogry.
// Main Tutorial page. This is where all your categories will be listed.
else if (!$category) {
//This makes a list of all the cateogries that are in the database! No need to make the links yourself!
$result = mysql_query("SELECT DISTINCT category from $mysql_table ");
while($row = mysql_fetch_array($result)) {
// Showing all the categories
echo "
<a href='tutorials.php?category=".$row['category']."'
>".$row['category']."</a>rerererer<br>
"; // End of showing all the categories
} // End of grabbing unique categories in database
}// End of main tutorial page
include "Template_Footer.php";
?>
Tutorial system grrr
Started by Bl4ck-Vip3r, Mar 17 2007 11:15 AM
1 reply to this topic
#1
Posted 17 March 2007 - 11:15 AM
I have a tms and have altered it a lil but to make it flow easier and so it wont disrupt my layout (it used to use exit(); but it cut off my footer so i added if else statements... everything works good but right at the bottom there is the show cats (if no cat id is set it will show all catagories........... but welll ........ it doesnt :S any help? 
#2
Posted 17 March 2007 - 03:31 PM
I would do something like this
Their could be a easier way to do it, but idk it yet
if (!isset($id) AND !isset($category)) {
// Show All categories
}
else if (isset($id) AND !isset($category)) {
// Show All categories
}
else if (!isset($id) AND isset($category)) {
// Show All Tutorial in that category
}
else if (isset($id) AND isset($category)) {
// Show that Tutorial
}
else {
// Error code
}
Their could be a easier way to do it, but idk it yet
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
