Reply
Old 10-19-2009, 07:26 AM pagination in menu
Average Talker

Posts: 22
Name: lakshmi
Trades: 0
hi,
this is my menu code
when pagination is clicked, the pagination page will be displayed in div class of this page.
but when link in pagination is clicked it is redirecting to pagination page,

but i want it to be displayed in menu page itself.
please help,

i am waiting for the result.
thanking u in advance.

menu.php
PHP Code:
<ul id="nav" class="dropdown dropdown-linear">
 
<
li>
<
a href="#" id="pagination">pagination</a>
</
li>
 
</
ul>
 
<
table width="100%" border="1" cellpadding="0" cellspacing="0">
<
tr valign="top">
<
td>
<
div id="result" class="functions">
 
</
div>
</
td>
</
tr>
</
table>
<
script type="text/javascript" src="jquery-1.2.6.min.js"></script>
<script type="text/javascript">
$.ajaxSetup ({
cache: false
});
var ajax_load = "<img src='images/load.gif' class='loading' alt='loading...' />";
//load() functions
 
$("#pagination").click(function(){
$("#result")
.html(ajax_load).load("pagination.php");
});
 
</script>
 
 
 
and
paginationpage.php
 
$page_name="pagination.php"; 
$start=$_GET['start'];
if(strlen($start) > 0 and !is_numeric($start)){
echo "Data Error";
exit;
}
$eu = ($start - 0); 
$limit = 10; $this1 = $eu + $limit; 
$back = $eu - $limit; 
$next = $eu + $limit; 
 
$query2=" SELECT * FROM footer_languages";
$result2=mysql_query($query2);
echo mysql_error();
$nume=mysql_num_rows($result2);
$query=" SELECT * FROM footer_languages limit $eu, $limit ";
$result=mysql_query($query);
echo mysql_error();
 
while($row = mysql_fetch_array($result))
{
print "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$row['languages'] ."";
}
echo "</table>";
if($nume > $limit ){
echo "<table align = 'center' width='50%'><tr><td align='left' width='30%'>";
if($back >=0) { 
print "<a href='$page_name?start=$back'>PREV</font></a>"; 

echo "</td><td align=center width='30%'>";
$i=0;
$l=1;
for($i=0;$i < $nume;$i=$i+$limit){
if($i <> $eu){
echo " <a href='$page_name?start=$i'>$l</font></a> ";
}
else { echo "$l</font>";} $l=$l+1;
}
echo "</td><td >";
if($this1 < $nume) { 
print "<a href='$page_name?start=$next'>NEXT</font></a>";} 
echo "</td></tr></table>";
}
?>
</div> 

Last edited by chrishirst; 10-19-2009 at 08:01 AM.. Reason: added php code delimiters
lakshmiyb is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 10-19-2009, 07:38 AM Re: pagination in menu
lizciz's Avatar
Ultra Talker

Posts: 330
Name: Mattias Nordahl
Location: Sweden
Trades: 0
I think you should change this

$("#result").html(ajax_load).load("pagination.php" );

into this

$("#result").load("pagination.php");
__________________
596f75206d65616e20796f752063616e2061637475616c6c79 207265616420746869733f
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 10-19-2009, 07:42 AM Re: pagination in menu
Average Talker

Posts: 22
Name: lakshmi
Trades: 0
no ,it is not displaying what i want
lakshmiyb is offline
Reply With Quote
View Public Profile
 
Old 10-19-2009, 08:49 AM Re: pagination in menu
lizciz's Avatar
Ultra Talker

Posts: 330
Name: Mattias Nordahl
Location: Sweden
Trades: 0
So what is it displaying then?
__________________
596f75206d65616e20796f752063616e2061637475616c6c79 207265616420746869733f
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 10-19-2009, 08:57 AM Re: pagination in menu
Average Talker

Posts: 22
Name: lakshmi
Trades: 0
ajax_load is an image of loading, when there is no page it will show the load image, so there will never be any change with r with out (ajax_load)
lakshmiyb is offline
Reply With Quote
View Public Profile
 
Old 10-19-2009, 11:06 AM Re: pagination in menu
lizciz's Avatar
Ultra Talker

Posts: 330
Name: Mattias Nordahl
Location: Sweden
Trades: 0
I don't know if this will make any difference, but the only things I can come up with is:

1) Move your script to the <head> section, instead of in the <body>. All javascript should normally be there.

2) Surround all your jQuery code with the ready() function. When I used jQuery I learned that all code must be in there, to make sure the page is ready before calling any jQuery functions.
Code:
$(document).ready(function(){
   // All your code goes here
});
__________________
596f75206d65616e20796f752063616e2061637475616c6c79 207265616420746869733f
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 10-20-2009, 03:28 AM Re: pagination in menu
Average Talker

Posts: 22
Name: lakshmi
Trades: 0
no change in the result

i think there must be change in
print "<a href='$page_name?start=$back'>PREV</font></a>";

because when prev or next is clicked it is moving to $page_name i.e, pagination page but i want it to redirect it to menu.php result in div class
lakshmiyb is offline
Reply With Quote
View Public Profile
 
Old 10-20-2009, 07:40 AM Re: pagination in menu
lizciz's Avatar
Ultra Talker

Posts: 330
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Aha, I think I just understood the problem :P
When you click "pagination" the pagination page opens correctly, but when you click a link in the pagination page it reloads the entire page? I thought it was the first step that didn't work.

Try adding some jQuery to the pagination page, that makes all the links open in a div. Something like
Code:
$(document).ready(function(){
   $(".link").click(){
      $("#your_div").load($(this).attr("href"));
      return false;
   };
});
And add the class "link" to all your links in pagination.php, as in
PHP Code:
echo '<a href="some_page.php" class="link">Some link</a>'
I'm not really that good with jQuery, but I think this will make all the links on the page load the address given by the links' href attribute, into your div with the id "your_div".
__________________
596f75206d65616e20796f752063616e2061637475616c6c79 207265616420746869733f
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 10-21-2009, 03:03 AM Re: pagination in menu
Average Talker

Posts: 22
Name: lakshmi
Trades: 0
NO, there is no change in my output
the link is in pagination page but not in to menu page.
lakshmiyb is offline
Reply With Quote
View Public Profile
 
Old 10-21-2009, 07:30 AM Re: pagination in menu
lizciz's Avatar
Ultra Talker

Posts: 330
Name: Mattias Nordahl
Location: Sweden
Trades: 0
I just tried this at my computer and got it to work. I'll post my example code and you can try to work something out from it.

Open page1.htm. The first link will open page2 in a div, then the links in page2 will open page3 (and 4, 5) in the seccond div.

page1.htm
HTML Code:
<html>

<head>
<title>Page1</title>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
   $("#link1").click(function(){
      $("#div1").load("page2.htm");
   });
});
</script>
</head>

<body>
<a href="#" id="link1">Click this to bring up page2</a>
<br />
<div id="div1" style="width:600px; height:200px; border:1px solid #000;"></div>
<br /><br />

Page 3, 4 and 5 will open here
<div id="div2" style="width:600px; height:300px; border:1px solid #000;"></div>
</body>

</html>
page2.htm
HTML Code:
<script type="text/javascript">
$(document).ready(function(){
   $(".link2").click(function(){
      $("#div2").load($(this).attr("href"));
      return false;
   });
});
</script>
<br />
<a href="page3.htm" class="link2">Click to open page 3</a>
<a href="page4.htm" class="link2">Click to open page 4</a>
<a href="page5.htm" class="link2">Click to open page 5</a>
<br />
And then I have page3.htm, page4.htm and page5.htm with only
HTML Code:
<h1>page 3/4/5</h1>
And also, of course, don't forget the jquery file.
__________________
596f75206d65616e20796f752063616e2061637475616c6c79 207265616420746869733f
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 10-21-2009, 09:04 AM Re: pagination in menu
Average Talker

Posts: 22
Name: lakshmi
Trades: 0
thank u very much,

I got it working in same div class with out taking another div class

i am greatfull to u

thanku once again for a great help
lakshmiyb is offline
Reply With Quote
View Public Profile
 
Old 10-21-2009, 09:07 AM Re: pagination in menu
Average Talker

Posts: 22
Name: lakshmi
Trades: 0
hi,
i need sql query for searching the all the tables of database and displaying the result,
if u can help me thanku.
lakshmiyb is offline
Reply With Quote
View Public Profile
 
Old 10-21-2009, 07:34 PM Re: pagination in menu
lizciz's Avatar
Ultra Talker

Posts: 330
Name: Mattias Nordahl
Location: Sweden
Trades: 0
You'll get much results if you search Google for "php mysql search" or similar, but basically what you want to do is

SELECT * FROM your_table WHERE field LIKE '$search'

where field is the database table field name you want to search in and $search is the word that the user entered to search for.
__________________
596f75206d65616e20796f752063616e2061637475616c6c79 207265616420746869733f
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 10-22-2009, 03:27 AM Re: pagination in menu
Average Talker

Posts: 22
Name: lakshmi
Trades: 0
thank u for the reply,

i have the query for the table search,
i have a doubt about the query
how to search the whole database of the site, the search which will be placed at the main page of the site
lakshmiyb is offline
Reply With Quote
View Public Profile
 
Old 10-22-2009, 04:59 AM Re: pagination in menu
lizciz's Avatar
Ultra Talker

Posts: 330
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Well it all depends on how your database is structured and how many tables/fields you want to search in. For searching in several fields you can just expand it into

SELECT * FROM your_table WHERE field1 LIKE '$search' OR field2 LIKE '$search' OR field3 LIKE '$search' ...

As I siad, you should be able to find alot of info of this by searching Google.
__________________
596f75206d65616e20796f752063616e2061637475616c6c79 207265616420746869733f
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 10-22-2009, 05:25 AM Re: pagination in menu
Average Talker

Posts: 22
Name: lakshmi
Trades: 0
ok, thanku very much
lakshmiyb is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to pagination in menu
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.15147 seconds with 13 queries