By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,664 Members | 1,623 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,664 IT Pros & Developers. It's quick & easy.

link-question

P: n/a
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("SELECT ID, tekst, DATE_FORMAT(dato, '%d %m %Y
kl. %H:%i')as dato FROM henriks ORDER BY ID desc LIMIT 0,3");
while ($raekke = mysql_fetch_array($result)){

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

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

?>

Regards Ricki
Jul 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

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:


Offcourse; it seems obvious. Thank you!

Ricki
Jul 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.