Jump to content

Archived

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

t3od0r

need help with this code

Recommended Posts

i have a problem with my jokesite and i couldnt find help nowhere else

at the bottom of the page there is << 1 2 3 >> number for other pages

but the link on those numbers are "/jokes_category.php?from=y&" y is where the numbers of jokes on the page and follow on but it should be like "/jokes_category.php?from=y&cat_id=x" X is where the number of category

for example when i have 15 jokes in category number 2 and its showing ten on one page and 15 on other so the link for the next page shud be like this "/jokes_category.php?from=10&cat_id=2" BUT it makes the link like this "/jokes_category.php?from=10&" where "cat_id=2 is missing...

The code is [url=http://www.uploading.com/files/F6H4OT7J/php.txt.html]here[/url] and the php code for this i think start's from the line 727.

where could be the problem...

thankx for any kind of help

sorry for my bad english  ;D


[code]// Next prevoius using numbers
/****************************************************/
function make_next_previous_with_number($from, $SQL, $filename, $vars, $display_nr)
{

$count = bx_db_num_rows(bx_db_query($SQL));
@$active = ($from+$display_nr) / $display_nr;
@$total_pages =  ceil($count/$display_nr);

if ($active <= $display_nr)
{
if ($active>1)
{
echo "<a href='".$filename."?from=0&".$vars."'><img src=\"".DIR_IMAGES."first.gif\" border=\"0\"></a>&nbsp;&nbsp;<a href='".$filename."?from=".($active*$display_nr-2*$display_nr)."&".$vars."'><img src=\"".DIR_IMAGES."previous.gif\" border=\"0\"></a>&nbsp;&nbsp;";
}

for ( $i = 1 ; $i <($active + $display_nr) && $total_pages >=$i ; $i++ )
{
if ($active == $i)
{
if ($count > $display_nr)
echo "<b>".$i."</b> ";
}
else
echo "<a href='".$filename."?from=".($i*$display_nr-$display_nr)."&".$vars."'>".$i."</a> ";
}
if ($count > $active && $count > $active*$display_nr)
{
echo "&nbsp;&nbsp;<a href='".$filename."?from=".($active*$display_nr)."&".$vars."'><img src=\"".DIR_IMAGES."next.gif\" border=\"0\"></a>";
echo "&nbsp;&nbsp;<a href='".$filename."?from=".(ceil($count/$display_nr)*$display_nr-$display_nr)."&".$vars."'><img src=\"".DIR_IMAGES."last.gif\" border=\"0\"></a>";
}
}
else
{

if ($active>1)
{
echo "<a href='".$filename."?from=0&".$vars."'><img src=\"".DIR_IMAGES."first.gif\" border=\"0\"></a>&nbsp;&nbsp;<a href='".$filename."?from=".($active*$display_nr-2*$display_nr)."&".$vars."'><img src=\"".DIR_IMAGES."previous.gif\" border=\"0\"></a> ";
}

for ( $i = $active - $display_nr ; $i < ($active + $display_nr) && $total_pages >= $i ; $i++ )
{
if ($active == $i)
echo "<b>".$i."</b> ";
else
echo "<a href='".$filename."?from=".($i*$display_nr-$display_nr)."&".$vars."'>".$i."</a> ";
}

if ($count > $active * $display_nr)
{
echo "<a href='".$filename."?from=".($active*$display_nr)."&".$vars."'><img src=\"".DIR_IMAGES."next.gif\" border=\"0\"></a>";
echo "&nbsp;&nbsp;<a href='".$filename."?from=".(ceil($count/$display_nr)*$display_nr-$display_nr)."&".$vars."'><img src=\"".DIR_IMAGES."last.gif\" border=\"0\"></a>";
}
}

}[/code]

Share this post


Link to post
Share on other sites
Can't you just post the relevant piece of code here...?

Orio.

Share this post


Link to post
Share on other sites
Hello, I had this script to display my news content on one area of my website. What it basically does it it displays all the news contents all at once. Could you please help me revise the script so I can only display two or five news content at a time. Below is the actual php script:

<?php
$data = file('data/news.db');
$data = array_reverse($data);
foreach($data as $element) {
    $element = trim($element);
    $pieces = explode("|", $element);
    echo "<h1>" . $pieces[0] . "</h1>" . "<p>" . $pieces[2] . "</p>";
  }
?>

Here is the actual news content format it parses on the website which is basically saved on a .txt file:

03.20.06|Raphael|test news
03.25.06|Raphael|test news
03.29.06|Raphael|test news

I am looking forward for any help you can offer. Thank you in advance.

Share this post


Link to post
Share on other sites
respiritu, please move your question to another topic.  Being polite wouldn't hurt either.

t3od0r, the lines looking like this generate the links:

[code]echo "<a href='".$filename."?from=".($i*$display_nr-$display_nr)."&".$vars."'>".$i."</a> ";[/code]

The function uses "$vars" to add any additional variables, such as the category id you want to be included.  Somehow you will need to ensure that $vars, when given as an argument to make_next_previous_with_number(), is set to "cat_id=x".

If that makes no sense at all, post again and I'll explain further :)

Share this post


Link to post
Share on other sites
[quote author=respiritu link=topic=112457.msg462070#msg462070 date=1162510753]
LOL! I pity you dude! You act like a kid who wants to have all the candies
[/quote]

It's not a matter of being childish.  It's a matter of sanity (that of everyone who tries to help) and politeness.  It can be VERY confusing to have two seperate questions running in the same thread.  If you had a question about some code that was posted as part of an answer to the original question, that wouldn't be too bad.

Share this post


Link to post
Share on other sites

×

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.