- Posts: 7
- Thank you received: 0
How to view most recent 25 posts
- tunafabulous
- Topic Author
- Offline
- New Member
Less
More
17 years 10 months ago #299
by tunafabulous
How to view most recent 25 posts was created by tunafabulous
Hello,
I was curious if there is a way to display ONLY the 25 most recent posts in my guestbook? I would then like to include a VIEW ALL POSTS link that is sorted by DESC. Any feedback or examples would be greatly appreciated.
Regards,
Tuna
I was curious if there is a way to display ONLY the 25 most recent posts in my guestbook? I would then like to include a VIEW ALL POSTS link that is sorted by DESC. Any feedback or examples would be greatly appreciated.
Regards,
Tuna
Please Log in or Create an account to join the conversation.
17 years 10 months ago #300
by Pete
DigiOz Webmaster
www.digioz.com
Replied by Pete on topic How to view most recent 25 posts
Hi,
I didn't have time to test this mod. But here is what you basically need to do:
Let me know if you get error messages.
I didn't have time to test this mod. But here is what you basically need to do:
Code:
=================== [ Open File list.php ] ===========================
--------------------- [ Replace Line 12 ] ----------------------------
$perpage = 10;
---------------------- [ With This ] ---------------------------------
$perpage = 25;
--------------- [ Replace Line 90 - 111 ] ----------------------------
echo "<center>";
// Creating the Forward and Backward links ----------------------
if ($fwd > 0 && $rwd > 0 && $rwd<$totalpages+1)
{
echo "<br><a href=\"list.php?page=$fwd&order=$order\"><<";
echo "<a href=\"list.php?page=$rwd&order=$order\">>><br>";
}
else if ($fwd == 0)
{ echo "<a href=\"list.php?page=$rwd&order=$order\">>><br>"; }
else if ($rwd == 0)
{ echo "<br><a href=\"list.php?page=$fwd&order=$order\"><<"; }
else if ($rwd == $totalpages+1)
{ echo "<a href=\"list.php?page=$fwd&order=$order\"><<<br>"; }
for ($i = 1; $i<=$totalpages; $i++)
{
echo " <b>[ <a href=\"list.php?page=$i&order=$order\"><b>$i</b> ]</b> ";
}
echo "</center>";
---------------------- [ With This ] ---------------------------------
echo "<center>";
echo "<a href=\"listall.php\">List ALL Entries";
echo "</center>";
------------------------- [ Copy ] -----------------------------------
File: list.php
----------------------- [ Rename To ] --------------------------------
File: listall.php
==================== [ Open listall.php ] ============================
--------------------- [ Replace Line 73 ] ----------------------------
for ($i=$end-1; $i>$start-2; $i--)
---------------------- [ With This ] ---------------------------------
for (count($lines); $i>$start-2; $i--)
Let me know if you get error messages.
DigiOz Webmaster
www.digioz.com
Please Log in or Create an account to join the conversation.
- tunafabulous
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
17 years 10 months ago #302
by tunafabulous
Replied by tunafabulous on topic How to view most recent 25 posts
Thanks Pete, I will give this a try later today and let you know the results.
Please Log in or Create an account to join the conversation.
- tunafabulous
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
17 years 10 months ago #308
by tunafabulous
Replied by tunafabulous on topic How to view most recent 25 posts
Hi Pete,
It appears as though your code would work, however the Guestbook that I am working with has been slightly customized. Hopefully you can assist with this fairly simple modification. There is a template.php file that acts as list.php and all the data writes to 50 state.php files. If you wish to view the website to get a better understanding www.countrywidehomeloansucks.com/index2.html
Here is the file structure of the Guestbook
1= root/
2= root/horror-stories
3= root/horror-stories/data
1 contains the following files
template.php
(all 50 states are listed ex.Arizona.php)
2 contains the following files
All of the Guestbook Files
3 contains the following files
(all 50 states are listed ex.Arizona.txt)
Here is the code from the template.php file which originated from list.php
Any assistance would be much appreciated.
It appears as though your code would work, however the Guestbook that I am working with has been slightly customized. Hopefully you can assist with this fairly simple modification. There is a template.php file that acts as list.php and all the data writes to 50 state.php files. If you wish to view the website to get a better understanding www.countrywidehomeloansucks.com/index2.html
Here is the file structure of the Guestbook
1= root/
2= root/horror-stories
3= root/horror-stories/data
1 contains the following files
template.php
(all 50 states are listed ex.Arizona.php)
2 contains the following files
All of the Guestbook Files
3 contains the following files
(all 50 states are listed ex.Arizona.txt)
Here is the code from the template.php file which originated from list.php
Code:
<?php
include($_SERVER['DOCUMENT_ROOT']."/horror-stories/header.php");
$page = $_GET['page'];
$order= $_GET['order'];
if ($page == "") { $page = 1; }
$fwd = $page - 1;
$rwd = $page +1;
// Setting the default values for number of records per page -------------------------
$perpage = 10;
$file = $_SERVER['DOCUMENT_ROOT']."/$state.php";
//$file = $_SERVER['DOCUMENT_ROOT']."/horror-stories/data/$state.txt";
$file = "horror-stories/data/" . $state . ".txt";
include($_SERVER['DOCUMENT_ROOT']."/".$file);
// Reading in all the records, putting each guestbook entry in one Array Element -----
$handle = fopen($file, "r");
if (filesize($file) == 0){ // mpg are there any entries to display
print "There are currently no entries to display"; // mpg no inform user
}
else
{
$datain = fread($handle, filesize($file));
fclose($handle);
$out = explode("<!-- E -->", $datain);
$outCount = count($out) - 1;
$j = $outCount-1;
if ($order == "desc")
{
for ($i=0; $i<=$outCount; $i++)
{
$lines[$j] = unserialize($out[$i]);
$j = $j - 1;
}
}
else
{
for ($i=0; $i<=$outCount; $i++)
{
$lines[$i] = unserialize($out[$i]);
}
}
// Counting the total number of entries (lines) in the data text file ----------------
$result = count($lines);
$count = $result-1;
//echo $count."<br>";
// Caclulate how many pages there are ----------------------------------------
if ($count == 0) { $totalpages = 0; }
else { $totalpages = intval(($count - 1) / $perpage) + 1; }
$page = $totalpages - ($page - 1);
$end = $count - (($totalpages - $page) * $perpage);
$start = $end - ($perpage - 1); if ($start < 1) { $start = 1; }
//$end = ($perpage * $page) - 1;
//$start = $end - $perpage;
if ($start < 0) { $start = 0; }
//for ($i = $end; $i>=($start-1); $i--)
//for ($i = 0; $i<$outCount; $i++)
//for ($i=$start-1; $i<$end; $i++)
for ($i=$end-1; $i>$start-2; $i--)
{
//echo $i."<br>end-".$end."-start-".$start;
echo "<table bgcolor=#EFEFEF bordercolor=#C0C0C0 border=1 width=500 cellspacing=0
cellpadding=10><tr><td background=\"/horror-stories/images/toolbar.jpg\" height=\"20
\"></td></tr><tr><td>";
echo "<b>$listDatetxt: </b>";
$lines[$i]->showDate();
echo "<br><b>$listnametxt: </b>";
$lines[$i]->showFrom();
echo "<br><b>$listemailtxt: </b><a href=\"mailto:";
$lines[$i]->showEmail();
echo "\">";
$lines[$i]->showEmail();
echo "<br><br><b>$listMessagetxt: </b>";
$lines[$i]->showMessage();
echo "</td></tr></table><br>";
}
echo "<center>";
echo "<a href=\"/$state.php\">List ALL Entries";
echo "</center>";
} // mpg end if
include($_SERVER['DOCUMENT_ROOT']."/footer.php");
?>
Any assistance would be much appreciated.
Please Log in or Create an account to join the conversation.
17 years 10 months ago #314
by Pete
DigiOz Webmaster
www.digioz.com
Replied by Pete on topic How to view most recent 25 posts
Sorry bud, I am kind of lost trying to find my way around your site.
Can you give me a direct link to the guestbook, so I can see what you are trying to do with it?
Can you give me a direct link to the guestbook, so I can see what you are trying to do with it?
DigiOz Webmaster
www.digioz.com
Please Log in or Create an account to join the conversation.
- tunafabulous
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
17 years 10 months ago #316
by tunafabulous
Replied by tunafabulous on topic How to view most recent 25 posts
The guest book is implemented for each of the state pages. It utilizes one template.php file which I have listed the code in my previous post.
SELECT A STATE FROM:
www.countrywidehomeloansucks.com/index2.html
Example:
www.countrywidehomeloansucks.com/Alabama.php
www.countrywidehomeloansucks.com/Alaska.php
www.countrywidehomeloansucks.com/Arkansas.php
Click add new entry if you wish to test.
SELECT A STATE FROM:
www.countrywidehomeloansucks.com/index2.html
Example:
www.countrywidehomeloansucks.com/Alabama.php
www.countrywidehomeloansucks.com/Alaska.php
www.countrywidehomeloansucks.com/Arkansas.php
Click add new entry if you wish to test.
Please Log in or Create an account to join the conversation.
Time to create page: 0.128 seconds