Holder Posted October 29, 2012 Share Posted October 29, 2012 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 I need more detailed info from someone how to fix this. If i add cat_id= after "&" and make it like this: echo "<a href='".$filename."?from=".($i*$display_nr-$display_nr)."&"."cat_id=".$vars."'>".$i."</a> "; i get at least this as link "/jokes_category.php?from=20&cat_id=" but i still need after id= to have 1 for the current category.. So please some freak help me Quote Link to comment https://forums.phpfreaks.com/topic/270016-pagination-script-problem-split-from-old-thread/ Share on other sites More sharing options...
btherl Posted October 29, 2012 Share Posted October 29, 2012 Holder, are you using the same function, make_next_previous_with_number()? Quote Link to comment https://forums.phpfreaks.com/topic/270016-pagination-script-problem-split-from-old-thread/#findComment-1388341 Share on other sites More sharing options...
Holder Posted October 29, 2012 Author Share Posted October 29, 2012 (edited) Holder, are you using the same function, make_next_previous_with_number()? Yes i am using the same site, and unfortunatly, i got the same problem. This is my function it's the same as his: (edit - On my first post i added altered by me function, this function is the default) /****************************************************/ // 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> <a href='".$filename."?from=".($active*$display_nr-2*$display_nr)."&".$vars."'><img src=\"".DIR_IMAGES."previous.gif\" border=\"0\"></a> "; } 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 " <a href='".$filename."?from=".($active*$display_nr)."&".$vars."'><img src=\"".DIR_IMAGES."next.gif\" border=\"0\"></a>"; echo " <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> <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 " <a href='".$filename."?from=".(ceil($count/$display_nr)*$display_nr-$display_nr)."&".$vars."'><img src=\"".DIR_IMAGES."last.gif\" border=\"0\"></a>"; } } } Edited October 29, 2012 by Holder Quote Link to comment https://forums.phpfreaks.com/topic/270016-pagination-script-problem-split-from-old-thread/#findComment-1388348 Share on other sites More sharing options...
btherl Posted October 29, 2012 Share Posted October 29, 2012 Ok, what I can tell from that code is that $vars does not have the expected value. $vars is an argument to make_next_previous_with_number(), so the problem lies somewhere else, in the code that calls this function. So you will need to track $vars back through the code to find where it is being set, and why it doesn't have the value you expect. Quote Link to comment https://forums.phpfreaks.com/topic/270016-pagination-script-problem-split-from-old-thread/#findComment-1388385 Share on other sites More sharing options...
PFMaBiSmAd Posted October 29, 2012 Share Posted October 29, 2012 Also, you should not be altering the code inside of that function to add your own key/value pairs to the pagination links, that's what the $vars parameter is for. Quote Link to comment https://forums.phpfreaks.com/topic/270016-pagination-script-problem-split-from-old-thread/#findComment-1388386 Share on other sites More sharing options...
Holder Posted October 29, 2012 Author Share Posted October 29, 2012 Well this is the script, that calls for this function (the big code down), and at the bottom you will find this code that calls the function and places the page system : $get_vars = "cat_id=".$cat_id; make_next_previous_with_number( $from, $SQL, $this_file_name, $get_vars ,$display_nr); What i see is that : $this_file_name, $get_vars are not the same as in general, in general it's filename instead of "this_file_name" and vars instead of get_vars is that a mistake, and if the problem is comming from here, how to fix it ? I am not very good at php, i am good designer and i worked hard to make new design for this site but this problem i did not see comming... <? include(DIR_LNG.'jokes_category_with_jokes_form.php'); if (!$HTTP_GET_VARS['cat_id']) $post_string = TEXT_ALL_CATEGORIES; else { $select_category_name_SQL = "select * from $database_table_name1 where category_id='".$HTTP_GET_VARS['cat_id']."'"; $select_category_name_query = bx_db_query($select_category_name_SQL); SQL_CHECK(0,"SQL Error at ".__FILE__.":".(__LINE__-1)); $select_category_name_result = bx_db_fetch_array($select_category_name_query); $post_string = "'<b>".$select_category_name_result['category_name'.$slng]."</b>' ".TEXT_CATEGORY; } ?> <tr valign="top"> <td> <? if($mode != "random" && $mode != "search") { $from = $HTTP_GET_VARS['from']; $result_array = step( $HTTP_GET_VARS['from'], $item_back_from, $SQL, $display_nr); } echo "<table width=\"100%\"><tr><td align=\"center\"><b><font size=\"3\" font-family=\"verdana\" color=\"".TOP_JOKES_PAGE_TITLE_FONTCOLOR."\">"." ".$type." ".$post_string." "."</font></td></tr></table><br></b>"; if (sizeof($result_array) == 0) { ?> <table align="center" border="0" cellspacing="0" cellpadding="0" width="100%"> <tr align="center"> <td colspan="4" align="center"> <table align="center" border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="<?=THERE_ARE_NO_JOKES_BORDERCOLOR?>"> <tr><td> <table align="center" border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="<?=THERE_ARE_NO_JOKES_INTERNAL_BGCOLOR?>"> <tr><td align="center" style="color:<?=THERE_ARE_NO_JOKES_FONT_COLOR?>"> <br><b><?=TEXT_NO_JOKES?></b><br><br> </td></tr></table> </td></tr></table> </td> </tr> </table> <? } for( $i = 0 ; $i < sizeof($result_array) ; $i++ ) { ?> <table align="center" border="0" cellspacing="0" cellpadding="1" width="90%"> <tr> <td background="images/head_bg.jpg" bgcolor="<?=SHORT_JOKE_TITLE_HEAD_BGCOLOR?>" width="5%"> <? $new_res = '<img src="'.HTTP_LANG_IMAGES.'new.gif" border="0" alt="">'; echo $new_res = (date('Y-m-d',mktime (0,0,0,date('m'),date('d')-$newperiod_for_jokes-1,date('Y'))) < $result_array[$i]['date_add'] ? $new_res : " "); ?> </td> <td background="images/head_bg.jpg" bgcolor="<?=SHORT_JOKE_TITLE_HEAD_BGCOLOR?>" align="center" width="95%"> <font size="<?=JOKE_TOPHEADER_FONT_SIZE?>" color="<?=JOKE_TOPHEADER_FONT_COLOR?>"><b><?=TEXT_JOKE_POSTED?></b> <b><?=$result_array[$i]['name'];?></b> <?=TEXT_AT?> <?=$result_array[$i]['date_add'];?></font> </td> </tr> <tr> <td colspan="2" bgcolor="<?=SHORT_JOKE_TITLE_BORDERCOLOR?>" > <table align="center" border="0" cellspacing="0" cellpadding="2" width="100%" bgcolor="<?=SHORT_JOKE_TITLE_BGCOLOR?>"> <? $get_extra= ($HTTP_POST_VARS['adv_search']=="1" || $HTTP_GET_VARS['adv_search']=="1" ? "&adv_search=1" : "").($HTTP_POST_VARS['x'] =="1" ? "&q_search=1" : ""); ?> <tr> <td colspan="2"> <font size="<?=SHORT_JOKE_TITLE_FONT_SIZE?>" color="<?=SHORT_JOKE_TITLE_FONTCOLOR?>"> <?=$from+$i+1?>.-</font> <a href="<?=HTTP_SERVER?>jokes.php?joke_id=<?=$result_array[$i]['joke_id']?><?=$get_extra?>&cat_id=<?=$HTTP_GET_VARS['cat_id']?>&jtype=<?=$jtype?>" style="text-decoration:none;color:<?=SHORT_JOKE_TITLE_FONTCOLOR?>;font-weight:bold"><?=$result_array[$i]['joke_title']?></a> <br> <font size="<?=SHORT_JOKE_TEXT_SIZE?>" color="<?=SHORT_JOKE_TEXT_COLOR?>"><?=short_string($result_array[$i]['joke_text'], $joke_listing_show_characters, "...");?></font> </td> </tr> <tr> <td align="right" style="font-size:9pt;color:<?=SHORT_JOKE_RATE_EMAIL_FONT_COLOR?>" colspan="2"> <b><?=TEXT_RATE?> <? if($result_array[$i]['rating_value'] > 0) { for ($star=0;$star<$result_array[$i]['rating_value'] && $result_array[$i]['rating_value'] != '0';$star++ ) { echo "<img src=\"".DIR_IMAGES."star2.gif\" border=\"0\">"; } } elseif($result_array[$i]['rating_value'] == '0' || $result_array[$i]['rating_value']='NULL' || $result_array[$i]['rating_value']=='') echo "0"; ?> </b>, <b><?=TEXT_EMAILED?></b> <?=$result_array[$i]['emailed_value'];?> </td> </tr> </table> </td> </tr> </table> <br> <? } ?> <table align="center" border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td> <? $get_vars = "cat_id=".$cat_id; make_next_previous_with_number( $from, $SQL, $this_file_name, $get_vars ,$display_nr); ?> </td> </tr> </table> </td> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/270016-pagination-script-problem-split-from-old-thread/#findComment-1388404 Share on other sites More sharing options...
Holder Posted October 30, 2012 Author Share Posted October 30, 2012 Please somebody help me. If no one can help me even here i don't know where to look.. Quote Link to comment https://forums.phpfreaks.com/topic/270016-pagination-script-problem-split-from-old-thread/#findComment-1388653 Share on other sites More sharing options...
PFMaBiSmAd Posted October 30, 2012 Share Posted October 30, 2012 (edited) 1) $HTTP_GET_VARS was depreciated over 10 years ago. All occurrences of $HTTP_GET_VARS should be changed to $_GET 2) There's no line of code in that code that is setting the $cat_id variable from $_GET['cat_id']. $cat_id is not defined and would be producing a php error message when it is referenced. 3) You need to have php's error_reporting set to E_ALL and display_errors set to ON to get php to help you find problems in the code you are trying to use. You will save a TON of time. 4) $vars is the name of that function's parameter, in the function definition, and only matters in that function definition. When you call that function, you are supplying a value at that parameter's position. It doesn't matter where that value comes from. It can be a literal value, some variable $abc, or in this case $get_vars, or even the returned value from some other function call. Edited October 30, 2012 by PFMaBiSmAd missed the 's' on end of $var Quote Link to comment https://forums.phpfreaks.com/topic/270016-pagination-script-problem-split-from-old-thread/#findComment-1388719 Share on other sites More sharing options...
Holder Posted October 30, 2012 Author Share Posted October 30, 2012 Man i rly don't know PHP i don't undarstand the 90% of what you said. I was under the impression, that this is ready system and that it's working. I didn't know i would have to do work on it if i knew i never would have started this, but now i wasted too much time on it, and i can't fix this problem. If something is missing can you put it there and make it work i rly tried for hours i just don't know PHP and after this topic was reviewd 60 times by now i'm guessing it's not simple thing to fix, and from those 60 people that saw that topic maybe 90% of them know better the PHP then me.. and they couldn't do it, so how can i. So please make it work, i know no one owes me anything but please, someone make it work.. Quote Link to comment https://forums.phpfreaks.com/topic/270016-pagination-script-problem-split-from-old-thread/#findComment-1388741 Share on other sites More sharing options...
PFMaBiSmAd Posted October 30, 2012 Share Posted October 30, 2012 (edited) Did you try any of the things I suggested? #1 is a search and replace operation in your programming editor. #2 is a php assignment statement, i.e. the thing you learned right after learning how to do <?php echo 'Hello World'; ?>, and I even listed the variable names that would be used in the assignment statement. How to do #3 is some basic research. #4 is information to answer your question about the naming of function parameters and call time values. The issue isn't because this is too hard to solve, it's because it's basic programming 101. To use an analogy, we don't mind pointing the way to the restroom, but don't expect us to go in with you, unzip your trousers, take it out, hold it for you, shake it off, put it back in, and zip you up. Programming is a do it yourself task. If you are at the point of needing someone to tell you what to type and where to type it at in your code, "You are not yet ready to leave the temple, Grasshopper." Edited October 30, 2012 by PFMaBiSmAd Quote Link to comment https://forums.phpfreaks.com/topic/270016-pagination-script-problem-split-from-old-thread/#findComment-1388771 Share on other sites More sharing options...
Muddy_Funster Posted October 30, 2012 Share Posted October 30, 2012 .... and from those 60 people that saw that topic maybe 90% of them know better the PHP then me.. and they couldn't do it, so how can i. ..... That's not generally how we roll here. I think you will find that most other viewers were much like myself - If there is nothing further to add that will be of further assistance at this point, let the OP work with the advice already on the table. This isn't a self gratification forum where people who can code come to write code for those who can't. I'll do my best to help people learn, but I'm not just going to race the others on here to script something up for every problem posted (and even if I did try that I would loose every time, but that's irrelivant). Try working with PFMaBiSmAd, he's trying to help you in a way that will make you better for the long term. And since we're throwing out analogys I know one about teaching a man to fish... Quote Link to comment https://forums.phpfreaks.com/topic/270016-pagination-script-problem-split-from-old-thread/#findComment-1388777 Share on other sites More sharing options...
Holder Posted October 30, 2012 Author Share Posted October 30, 2012 Well from one other forum helped, they sayd to changed it to $GET like you said, and i to add this: [color=#000000][color=#0000BB]$aQS [/color][color=#007700]= [/color][color=#0000BB]$_GET[/color][color=#007700]; unset([/color][color=#0000BB]$aQS[/color][color=#007700][[/color][color=#DD0000]'from'[/color][color=#007700]]); [/color] [color=#0000BB]$get_vars [/color][color=#007700]= [/color][color=#0000BB]http_build_query[/color][color=#007700]([/color][color=#0000BB]$aQS[/color][color=#007700]); [/color][/color] After that line make_next_previous_with_number( $from, $SQL, $this_file_name, $get_vars ,$display_nr); And i want to ask you, why it would be better to replace $HTTP_GET_VARS with $_GET ? Quote Link to comment https://forums.phpfreaks.com/topic/270016-pagination-script-problem-split-from-old-thread/#findComment-1388802 Share on other sites More sharing options...
Pikachu2000 Posted October 30, 2012 Share Posted October 30, 2012 $HTTP_GET_VARS is deprecated. Quote Link to comment https://forums.phpfreaks.com/topic/270016-pagination-script-problem-split-from-old-thread/#findComment-1388804 Share on other sites More sharing options...
btherl Posted October 30, 2012 Share Posted October 30, 2012 Try adding this line: $cat_id = $_GET['cat_id']; # <-- Add this $get_vars = "cat_id=".$cat_id; make_next_previous_with_number( $from, $SQL, $this_file_name, $get_vars ,$display_nr); No guarantees but if it works, it'll be a simple solution and you won't need to get into the code in detail. Quote Link to comment https://forums.phpfreaks.com/topic/270016-pagination-script-problem-split-from-old-thread/#findComment-1388859 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.