Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    53
    Thanks
    11
    Thanked 2 Times in 2 Posts

    Using row id to rest of row.

    How would yo go about doing this?
    What i mean is if you had 3 columns (auto generated id, name, age)
    and you just wanted to call the id and have the rest of the row display
    when that id is called.

    Ex.) Table structure
    |id|subject|content|
    |1|subject1|content1|
    |2|subject2|content2|

    How would you echo the subject and content of a row by
    using the id to choose the row, Such as using news.php?article=2
    and it would echo subject2 and content2.

    -Thanks for the help

    edit: messed the post title up :/

  • #2
    New Coder
    Join Date
    Jun 2007
    Posts
    60
    Thanks
    7
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?php

    $id 
    $_GET['id'];

    $sql mysql_query("SELECT * FROM tablename WHERE id='$id'") or die(mysql_error());
    while (
    $row mysql_fetch_array($sql)){
        
    $name $row['name'];
        
    $age $row['age'];
        echo 
    $name;
        echo 
    $age;
    }

    ?>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •