[Questions]Downloads system
Moderator: General Moderators
[Questions]Downloads system
Does any one have a basic manual or tutorial to make a Downloads System?[/php_man]
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
Well, I ve almost finished my script... Where I ve problems is the page where the downloads will be displayed(downloads.php)
I have a modular page... So, the path to the downloads is
index.php?page=downloads
Also, my downloads are divided in categories.... I have 2 tables(in mysql): downloads and downloads_category
Now I dont know how to show the downloads for example:
index.php?page=downloads&category=php
index.php?page=downloads&category=etc
If anyone have ideas how to it making mysql queries, please tell me... ur help would be appreciated...
Thanks in advance...
PD: I ve searched in google... And found this forum
I have a modular page... So, the path to the downloads is
index.php?page=downloads
Also, my downloads are divided in categories.... I have 2 tables(in mysql): downloads and downloads_category
Now I dont know how to show the downloads for example:
index.php?page=downloads&category=php
index.php?page=downloads&category=etc
If anyone have ideas how to it making mysql queries, please tell me... ur help would be appreciated...
Thanks in advance...
PD: I ve searched in google... And found this forum
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Use a switch statement to know which "page" to use. Have that page parse out whatever data it needs to display the output. If the category is empty (hint) or unknown display the default downloads page, otherwise construct a query based on the category which corresponds to the data in downloads_category.
this can be done somewhat like this example:
this can be done somewhat like this example:
Code: Select all
<?php
$category = (!empty($_GET['category']) ? $_GET['category'] : '' );
if(isset($cat_id)) unset($cat_id);
if(!empty($category))
{
if(get_magic_quotes_gpc())
$category = stripslashes($category);
$category = mysql_escape_string($category);
$sql = 'SELECT `category_name`, `category_id` FROM `downloads_category` WHERE `category_name` LIKE ''' . $category . '''';
$query = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($query) != 1)
$category = '';
else
{
list($category,$cat_id) = mysql_fetch_row($query);
}
}
$sql = 'SELECT * FROM `downloads`' . (isset($cat_id) ? ' WHERE `downloads_category_id` = ''' . $cat_id . '''' : '');
?>