Page 1 of 1

[Questions]Downloads system

Posted: Sun Jul 25, 2004 12:18 pm
by HaxXxess
Does any one have a basic manual or tutorial to make a Downloads System?[/php_man]

Posted: Sun Jul 25, 2004 1:23 pm
by tim
you could search this forum and find the necessary code.

google will get you far as well =]

Posted: Sun Jul 25, 2004 2:28 pm
by Illusionist
also, hotscripts.com might have something you're looking for.

Posted: Sun Jul 25, 2004 5:21 pm
by HaxXxess
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 ;)

Posted: Sun Jul 25, 2004 6:00 pm
by feyd
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:

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 . '''' : '');

?>

Posted: Sun Jul 25, 2004 10:25 pm
by HaxXxess
Thx bro... U gave the idea