link-question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ricki Susic

    link-question

    Hi ( and I'm sorry in advance ),
    I have looked in php.net but I can't figure out how it's done.
    I want to show a list of the three latest inserted posts in a mysql-table.
    The list is meant to be an apertizer and the users have to click on it to
    see the whole output from the DB.
    How do I make the link to open that exact post?

    Here is what is working for now:

    <?php

    $link = mysql_connect(" server", "user", "pass")
    or die("Could not connect: " . mysql_error());
    print ("Connected successfully");
    mysql_select_db ("database") ;
    $result = mysql_query("SE LECT ID, tekst, DATE_FORMAT(dat o, '%d %m %Y
    kl. %H:%i')as dato FROM henriks ORDER BY ID desc LIMIT 0,3");
    while ($raekke = mysql_fetch_arr ay($result)){

    echo"<P> ID: ".$raekke['ID']."<br>";
    $text = $raekke['tekst'];

    echo"Tekst: ".nl2br(substr( $text,0,50)).". ...";
    echo"<BR>Dato: ".$raekke['dato'];
    }

    ?>

    Regards Ricki


  • Ricki Susic

    #2
    Re: link-question

    [color=blue]
    >
    > Create another php page that expects the ID as a GET variable
    > as you loop through your dataset (as per your code snippet) do
    > something like the following:
    >
    > print "<a href='showpost. php?id={$raekke["ID"]}'>Some Text</a>";
    >
    > Then showpost.php:[/color]

    Offcourse; it seems obvious. Thank you!

    Ricki


    Comment

    Working...