displaying data from database..i have two tables

Discussion in 'PHP' started by irkevin, Aug 5, 2007.

  1. #1
    Hi everyone, I'm kevin and new to this forum..

    I need some help :(

    on my website, i have a list like this

    bleach
    naruto
    saint seiya

    now just for example, when i click on bleach, i want it to display the information about bleach (the same way i inserted it in my dabatase) on a page.. then when i click on naruto, i want it to display only naruto's information on the same page.. See what i mean? and so on. when i click on saint seiya, it shows only information about saint seiya..etc etc..

    is there a way to do that?

    For some more explanation, i have two tables..

    #multimedia
    mult_id
    mult_name

    i.e of mult_name : Bleach, naruto etc!

    then the second table

    #multi_file
    file_id
    mult_id
    file_name
    file_description
    file_link

    So basically, file_id is primary and auto increment ..

    Now i do I proceed if i want to display only bleach info when i click on bleach, and antoher one info when i click on it?

    i really want to figure this out :(
     
    irkevin, Aug 5, 2007 IP
  2. ecentricNick

    ecentricNick Peon

    Messages:
    351
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi irkevin.

    This is quite straightforward and I'd proceed ike this.

    When you display your clickable list of names, ensure they are done like so...

    <a href="yourpage.php?mult_id=N"> where N is your multid.

    in your page you can then reference the id using $_GET['mult_id']

    then you can use that to select the main information...

    "SELECT * FROM multi_file WHERE mult_id = ".$_GET['mult_id']
     
    ecentricNick, Aug 5, 2007 IP
  3. irkevin

    irkevin Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    im so glad u replied.. i'll try it.. by the way.. if u have msn messenger.. just add me irkevin@hotmail.com
     
    irkevin, Aug 5, 2007 IP
  4. irkevin

    irkevin Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    is there a way i could link these two tables?
     
    irkevin, Aug 5, 2007 IP
  5. ecentricNick

    ecentricNick Peon

    Messages:
    351
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #5
    It depends on what you mean by "link"?

    If you want to combine data from the two tables in one sql command (known in the trade as a "join") then you can like so...

    SELECT * FROM table1,table2 where table1.commonId = table2.commonId

    So, for your tables it would be...

    SELECT * FROM multimedia,multi_file where multimedia.mult_id = multi_file.mult_id

    You can choose which fields to select from both too...


    SELECT multi_file.name, multimedia.mult_name FROM multimedia,multi_file where multimedia.mult_id = multi_file.mult_id

    ...and so on.

    You'd save a lot of time if you read up on the basics of SQL and PHP before going much further.
     
    ecentricNick, Aug 6, 2007 IP