How Do I Create a Dynamic PHP Page from MySQL?

Discussion in 'PHP' started by amys101place, Dec 23, 2010.

  1. #1
    Here's my problem.. and I'm sure it's because I'm not quite grasping the passing of variables.

    MY MySQL Setup:
    I have 1 table called table1. It has 2 columns which are: 'Title' & 'Description'

    My Index.php Page:
    I connect to mysql. I pull the 'Title' from MySQL and loop it to produce 100 rows of data that fill my index page, as expected.

    My Problem:
    I now want to be able to click one of those rows and dynamically create a new page (description.php) that includes the 'Title' & 'Description'.

    My Progress:
    I've managed to click a row and create a hyperlink to mysite.com/title (where 'title' is pulling the 'title' from the mysql db) but I all I get is page not found.

    My Question:
    How do I tell description.php to pull the 'Title' and 'Description' and link to it from index.php?

    My Gratitude:
    Thanks in advance!
     
    amys101place, Dec 23, 2010 IP
  2. gapz101

    gapz101 Well-Known Member

    Messages:
    524
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    150
    #2
    dynamic page? .htaccess solves it
     
    gapz101, Dec 23, 2010 IP
  3. amys101place

    amys101place Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Did you read a single word before responding?
     
    amys101place, Dec 23, 2010 IP
  4. gapz101

    gapz101 Well-Known Member

    Messages:
    524
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    150
    #4
    of course yes. what did i miss?
     
    gapz101, Dec 23, 2010 IP
  5. krishmk

    krishmk Well-Known Member

    Messages:
    1,376
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    185
    #5
    From my POV, there are 2 ways of achieving this:
    Either you need to pass the values of title and description in the url parameter
    http://mysite.com/description.php?title=XYZ&description=My description
    [You need to encode the url in your index.php and decode it in your description.php page. Could also use base64_encode]

    OR
    assuming the "title" field is unique in your DB table.. In your description.php you need to query your database for the "title" and get the description.
    http://mysite.com/description.php?title=XYZ
    However if you want the URL structure to be same as you posted (mysite.com/title) then you need to create .htaccess file to recognize this url structure in your web server as the other member stated over here...
     
    krishmk, Dec 23, 2010 IP
  6. amys101place

    amys101place Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thx for the advice!
     
    amys101place, Dec 24, 2010 IP