Dynamic Links

Hi :slight_smile:
I have an website for articles. On the main page I show only the title and the description for the articles (in my database I have the fields: id, title, description, and text)
[php]
$result=mysql_query(“SELECT * FROM content ORDER BY id DESC”);

while($res=mysql_fetch_array($result)){

echo "<h2>".$res['title']."</h2>";
echo "<p>".$res['descrip']."</p>";

}
[/php]
How can I make dynamic link - when click on ‘title’ to show corresponding ‘text’?
Thank you!

I am not sure I am reading your questin right but will try to help.
I cannot tell you more because I do not know what title or descip contain.
[php]
while($i++ >=10 $res=mysql_fetch_array($result)){
echo “<a href=‘text.php?id=$res[‘id’].’ target=’_self’>

”.$res[‘title’]."

";
echo “

”.$res[‘descrip’]."

\r\n";
}

[/php]
new page with text.php
[php]
$id = $_GET[‘id’];

$result=mysql_query(“SELECT text FROM content WHERE id=$id”);
while($q=mysql_fetch_array($result)){

echo "<p>".$q['text']."</p>";

}
[/php]

you might want to count as well as there maybe more than one.

Or maybe use session for the id to the new page $_SESSION[‘id’] = $res[‘id’];

Sponsor our Newsletter | Privacy Policy | Terms of Service