Php / Mysql - Help Please

Discussion in 'PHP' started by adamk1, Sep 13, 2007.

  1. #1
    hi there

    I am having a problem sorting out having a page for each row of my database, I have used the below query and it parse ok, but now how do I find out the url of other variables, It is my assumption example.com/index.php?id=2 or index.php?page=2 would show a different set of variables? this isnt happening how do I find the url ?!?:eek: In this example I was hoping it would change the news story so I can refrence them from the main page.

    Am I going about this in thr wrong way? I have never seen a tutorial on doing this, any help would be fantastic.


    <?php
    // Connects to your Database
    mysql_connect("localhost", "login", "password") or die(mysql_error());
    mysql_select_db("news") or die(mysql_error());

    // Query
    $id = $_GET['id'];
    $data = mysql_query("SELECT * FROM `news` WHERE `id`='.$id'") or die(mysql_error());


    // Results
    while($info = mysql_fetch_array( $data ))
    {
    Print "<center><b>".$info['title'] . " </b> - headline<br><br>";
    Print "<b>".$info['story'] . " <br>";
    }
    Print "</table>";
    ?>
     
    adamk1, Sep 13, 2007 IP
  2. alexts

    alexts Well-Known Member

    Messages:
    1,126
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    125
    Digital Goods:
    1
    #2
    I think you are missing the dot at the following line

    $data = mysql_query("SELECT * FROM `news` WHERE `id`='.$id.'") or



     
    alexts, Sep 13, 2007 IP
  3. adamk1

    adamk1 Active Member

    Messages:
    110
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #3
    It does parse correctly as it is, I will try it however, how do I find what the url is for the variable

    I want to input data into my database and it create a new web page automaticly using id variables so I dont have to do hundeads of web pages with different content which look exactly the same. I am quite new to php and this seems a simple skill which I have not been able to master which is frustrating me.
     
    adamk1, Sep 13, 2007 IP