Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Show data using ID

  1. #1
    Join Date
    May 2006
    Posts
    266
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Show data using ID

    Hi i have a database called funny the table is called jokes
    in there i have a list of jokes all done by ID

    i need a way to fetch them like
    joke number 1

    i would it to show in the address bar something like this
    http://www.mywebsite.com/joke.php?ID=1

    or
    http://www.mywebsite.com/TitleOfJoke

    and i need to figger out how to show that joke on the page

    Thanks
    The web in one word.

  2. #2
    Join Date
    Apr 2006
    Posts
    190
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default

    http://www.php-mysql-tutorial.com/

    Has alot of good MySQL and PHP tutorials. I suggest you check them out. If you still have problems post back here.

    Remember Google is your friend.

    Code:
    $id = $_GET["id"];
    Code:
    $sql = "SELECT * FROM jokes WHERE id = $id";
    Ryan
    Sevierville, TN

  3. #3
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Correction to your code...
    Code:
    $sql = "SELECT * FROM jokes WHERE id = $id" limit 0,1";
    Jeremy | jfein.net

  4. The Following User Says Thank You to Nile For This Useful Post:

    NXArmada (03-14-2008)

  5. #4
    Join Date
    May 2006
    Posts
    266
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thank you for the help, however it seems not to be working?

    This is my PHP code
    Code:
    <?php
    include 'include/config.php';
    include 'include/opendb.php';
    
    $id = $_GET["id"];
    $sql = "SELECT * FROM podcast WHERE id = $id";
    $result = mysql_query($query);
    
    while($row = mysql_fetch_array($result, MYSQL_ASSOC))
    {
        echo "Name :{$row['ID']} <br>" .
             "Subject : {$row['podcastname']} <br>" .
             "Message : {$row['xmllink']} <br><br>";
    } 
    
    include 'include/closedb.php';
    
    ?>
    The web in one word.

  6. #5
    Join Date
    May 2006
    Posts
    266
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I found this code but its not working PLZ help


    Code:
    <HTML>
    <?php
    $db = mysql_connect("localhost", "USERNAME", "PASSWORD");
    mysql_select_db("twitoo",$db);
    $result = mysql_query("SELECT * FROM podcast WHERE id=$id",$db);
    $myrow = mysql_fetch_array($result);
    echo "First Name: ".$myrow["firstname"];
    echo "<br>Last Name: ".$myrow["lastname"];
    echo "<br>Nick Name: ".$myrow["nick"];
    echo "<br>Email address: ".$myrow["email"];
    echo "<br>Salary: ".$myrow["salary"];
    ?>
    </HTML>
    Edit: Mod Edit: Took out db username and password. Please do not post this information in future posts.
    Last edited by thetestingsite; 03-16-2008 at 02:22 PM.
    The web in one word.

  7. #6
    Join Date
    May 2006
    Posts
    266
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Got It Working
    The web in one word.

  8. #7
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Try this:
    Code:
    <HTML>
    <?php
    $db = mysql_connect("localhost", "USERNAME", "PASSWORD");
    mysql_select_db("twitoo",$db);
    $result = mysql_query("SELECT * FROM podcast WHERE id=$id")or die(mysql_error());
    $myrow = mysql_fetch_array($result);
    echo "First Name: $myrow['firstname']";
    echo "<br>Last Name:$myrow['lastname']";
    echo "<br>Nick Name: $myrow['nick']";
    echo "<br>Email address: $myrow['email']";
    echo "<br>Salary: $myrow['salary']";
    ?>
    </HTML>
    Jeremy | jfein.net

  9. #8
    Join Date
    May 2006
    Posts
    266
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hey i need some more help Sorry

    I have this code that use to fetch the xml file from a URL however now that i have everything in the MySQL i need to make it also have the ?id=1 fuction

    Code:
    <?php
    
    /*
    You can use this script to pass-through a playlist from an external server to the players. 
    Just insert the url to external playlist below and copy this file to your server.
    You can use the flashvar "file=external_feed.php" in your HTML feed this script to the player.
    */
    
    
    // build file headers
    header("content-type:text/xml;charset=utf-8");
    // refer to file
    readfile("http://www.abc.net.au/tv/enoughrope/podcast.xml");
    // that's all
    exit();
    
    
    ?>
    If you can help Thank you so much
    The web in one word.

  10. #9
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    I don't get what you want. ożo
    Jeremy | jfein.net

  11. #10
    Join Date
    May 2006
    Posts
    266
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I would like to replace http://www.abc.net.au/tv/enoughrope/podcast.xml with what every the xml URL is in the MySQL

    so it would look like something like this
    http://www.mysite.com/xml.php?id=1

    Code:
    <?php
    
    /*
    You can use this script to pass-through a playlist from an external server to the players. 
    Just insert the url to external playlist below and copy this file to your server.
    You can use the flashvar "file=external_feed.php" in your HTML feed this script to the player.
    */
    
    
    // build file headers
    header("content-type:text/xml;charset=utf-8");
    // refer to file
    readfile("{$row['xmlURL']}");
    // that's all
    exit();
    
    
    ?>
    Thanks
    The web in one word.

Bookmarks

Posting Permissions

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