Jump to content

dynamic links and news entries


woolseyr

Recommended Posts

Hi what i am trying to do is create a page that will display the newest entry in the database and have all the other entries displayed as a link underneath as past entries.
I know i am missing some elements in my code. but i don't know what it is.

so far what i have is one page that list all the entries with there dates
and when you click on a links it calls a second page where it calls up the newest entry and links the older entries.
I would prefer if i could do this on one page. where the newest entry is displayed automatically. and the older links are under it.
Any help at all would be appreciated.
This is probably easy to do. but i cant find what i am looking for.


THis is my first page of the code
[code]<?php

include('../db_connect.php');
?>

<?php
$sql = "SELECT * FROM parentletter_en ORDER BY letter_id DESC";
$rs = mysql_query($sql) or
print ("Can't select entries from table Parent Letters.<br />" . $sql . "<br />" . mysql_error());

while ($info = @mysql_fetch_array($rs)) {
    echo "<a href='showdetails.php?id=" . $info['letter_id'] . "'>" . $info['date'] . "<p>";
}
?>[/code]


This is my second page of the code

[code]<?php

include('../db_connect.php'); ?>


<?php


$query = "SELECT letter_id, date, body FROM parentletter_en WHERE letter_id";

$result = mysql_query($query) or
print ("Can't select entries from table Parent Letters.<br />" . $query . "<br />" . mysql_error());
while($row = mysql_fetch_assoc($result))

    {
echo
        "<b><p><p>$date {$row['date']}</b></p></p><br><br>" .

        "$body {$row['body']}" ;


    }

?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/35264-dynamic-links-and-news-entries/
Share on other sites

what i want is something like this.
http://zenonpark.nesd.ca/en/listlinkies.php

But i want it to look like this right from the start
http://zenonpark.nesd.ca/en/showdetails.php

however it is supposed to only show the most recent entry.
and list the old entries like a link in the first page
I think it would be somthing like....
[quote]
Welcome to the admin panel. What will you do?
<ul>
<li><A href=addupdate.php>Add Update</a>
<li><a href=admin.php?view=donate>Donate</a>
<li><a href=admin.php?view=add>Add Staff</a>
</ul>
<?php
if ($view == del) {
print "<form method=post action=admin.php?view=del&step=del>Delete ID <input type=text name=did>. <input type=submit value=Delete></form>";
if ($step == del) {
if ($did != 1) {
mysql_query("delete from players where id=$did");
print "You deleted ID $did.";
} else {
print "No deleting the owner.";
}
}
}

if ($view == add) {
print "<form method=post action=admin.php?view=add&step=add>Add ID <input type=text name=aid> as an <select name=rank><option value=Member>member</option><option value=Admin>admin</option></select>. <input type=submit value=Add></form>";
if ($step == add) {
if ($aid != 1) {
mysql_query("update players set rank='$rank' where id=$aid");
print "You added ID $aid as a $rank.";
}
}
}
?>
</quote]

this is my admin panel and it works on the basis of what you want..
where it says print you'd simple replace it with a database script to call your info from the database i think..

letme know how it works out.
from trying the code (dont know if i did everything right). but its not working how i need it to.
what i am looking for is...

IF id is the newest in the list THEN print
the body of the letter.


IF it isnt newest in the list
then print
all the older entires as a link when clicked on opens up and you can view what it is.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.