PHP + mySQL Help

Discussion in 'PHP' started by TheBiaatch, Feb 5, 2009.

  1. #1
    Hi all,

    I am having this problem with a new system that I am building for listing downloads. It consists of 3 tables

    Info:
    que => Where all the downloads are stored before that are approved of an administrator
    sites =>The list of sites that have submitted the downloads
    downloads => where the approved downloads are

    Structure:
    que=> download_id, download_type, download_title, site_id
    sites => site_id, site_name, site_url, site_rating, email
    downloads => download_id, download_type, download_title, site_id

    I am now looking to display all the downloads in que sorted by site_rating DESC and then later on also insert them in this way in the downloads table so that the highest rated sites are above the lower rated ones.

    Help would be appreciated.

    Regards,
    TheBiaatch
     
    TheBiaatch, Feb 5, 2009 IP
  2. Gonzo4u

    Gonzo4u Well-Known Member

    Messages:
    410
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #2
    Hello TheBiaatch,

    To display the download list in que table sorted by site_rating DESC you can use this SELECT statement.

    SELECT que.*, sites.* FROM que, sites WHERE que.site_id = sites.site_id ORDER BY sites.site_rating DESC;

    Later you can use a INSERT statement to insert data into downloads table, you dont have to sort data while inserting them as you can retrieve the data in a sorted order for listing or display. eg:

    SELECT downloads.*, sites.* FROM downloads, sites WHERE download.site_id = sites.site_id ORDER BY sites.site_rating DESC;

    Hope you got your anwser.

    Regards,
    Gonzo
     
    Gonzo4u, Feb 6, 2009 IP
  3. TheBiaatch

    TheBiaatch Peon

    Messages:
    435
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the help so far, Im currently working on it and I have sent you a PM.
     
    TheBiaatch, Feb 6, 2009 IP
  4. Gonzo4u

    Gonzo4u Well-Known Member

    Messages:
    410
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #4
    You are welcome!

    Ya, I had replied to your PM as well.

    Gonzo
     
    Gonzo4u, Feb 6, 2009 IP