Jump to content


Photo

need help with this code


  • Please log in to reply
6 replies to this topic

#1 t3od0r

t3od0r
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 23 October 2006 - 06:28 PM

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 here 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


// 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>";
		}
	}

}


#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 23 October 2006 - 06:51 PM

Can't you just post the relevant piece of code here...?

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 respiritu

respiritu
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 24 October 2006 - 03:15 AM

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.

#4 t3od0r

t3od0r
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 24 October 2006 - 04:21 PM

And you couldn't start a new topic for your problem?

Somebody for my problem?

#5 respiritu

respiritu
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 02 November 2006 - 11:39 PM

LOL! I pity you dude! You act like a kid who wants to have all the candies

#6 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 03 November 2006 - 02:38 AM

respiritu, please move your question to another topic.  Being polite wouldn't hurt either.

t3od0r, the lines looking like this generate the links:

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

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 :)

#7 doni49

doni49
  • Members
  • PipPipPip
  • Advanced Member
  • 515 posts
  • LocationCentral MO

Posted 03 November 2006 - 02:46 AM

LOL! I pity you dude! You act like a kid who wants to have all the candies


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.
Don




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users