[Questions]Downloads system

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
HaxXxess
Forum Newbie
Posts: 4
Joined: Sat Jul 24, 2004 4:28 pm

[Questions]Downloads system

Post by HaxXxess »

Does any one have a basic manual or tutorial to make a Downloads System?[/php_man]
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

you could search this forum and find the necessary code.

google will get you far as well =]
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

also, hotscripts.com might have something you're looking for.
HaxXxess
Forum Newbie
Posts: 4
Joined: Sat Jul 24, 2004 4:28 pm

Post 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 ;)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

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

?>
HaxXxess
Forum Newbie
Posts: 4
Joined: Sat Jul 24, 2004 4:28 pm

Post by HaxXxess »

Thx bro... U gave the idea
Post Reply