General Community > Scripting Help

PHP shouldn't show an "Older" button

(1/1)

Doctor Deejay:
Hi all! :) I was about to release my blogging software, so I decided to throw an alpha version to Yoshi, we tested it out for a while and we came to the conclusion that the pagination script.. well, it sucks. :( So here is what it does: it displays the 'older' button correctly, but it's a bit enthusiastic and shows an 'Older' button too when there are no things left on the next page. I've tried several things, but I can't get it fixed. Could someone please take a look at it? :)

This is the code that should display it:

--- Code: --- // Do we even NEED to show more?
if(($vienara['show'] > ($vienara['blog_count'] -1)) && ($vienara['blogs_to_show'] < $vienara['setting']['blogsperpage'])) {

// Output the button.
if($vienara['setting']['order'] == 'asc')
echo '
<a href="' . Blog_file . '?show=' . $vienara['show'] . '" class="more whitelink">' . show_string('newer') . '</a>';
else
echo '
<a href="' . Blog_file . '?show=' . $vienara['show'] . '" class="more whitelink">' . show_string('older') . '</a>';
}
--- End code ---

And this is the piece of code that gets the variables:

--- Code: ---// We need to calculate how many results we should show
if(isset($_GET['show']) && is_numeric($_GET['show']))
$vienara['show'] = $_GET['show'] + $vienara['setting']['blogsperpage'];
else
$vienara['show'] = $vienara['setting']['blogsperpage'];

// We should begin with a specific number of blogs. How many?
if(!empty($_GET['show']) && is_numeric($_GET['show']))
$vienara['blogs_to_show'] = $_GET['show'];

// Just begin with the first blog.
else
$vienara['blogs_to_show'] = 0;
--- End code ---

And this gets the blog count:

--- Code: ---// Get the blogcount
$vienara['blog_count'] = xensql_count_rows("
RETRIEVE id_blog, blog_title, blog_content, published, post_date
FROM {db_pref}content
WHERE published is equal to 1
");
--- End code ---

Thanks in advance! :)

Elmacik:
Where the $vienara['setting']['order'] var gets filled?

Doctor Deejay:
It's set with this code:

--- Code: ---// Retrieve the settings from the database
$result = xensql_query("
RETRIEVE id, value
FROM {db_pref}settings
");

// Merge them into a settings array
foreach($result as $setting)
$vienara['setting'][$setting['id']] = $setting['value'];
--- End code ---
:)

I've set it to desc btw. :P

Doctor Deejay:
Nevermind, I've solved it by replacing it with a real pagination script rather than an 'older/newer' thing. :P

* Dr. Deejay hits the topic solved button

Navigation

[0] Message Index

Go to full version