User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,554 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,457 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1478 | Replies: 16 | Solved
Reply
Join Date: Jul 2005
Posts: 20
Reputation: ploppy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ploppy ploppy is offline Offline
Newbie Poster

Re: pagination not displaying results

  #11  
Oct 20th, 2007
hi kkeith. time is not a problem, just grateful for your help & experience. if you could amend with url would be grateful. what url do you need. page2 should go to:

http://localhost/public_html/cp/data.php?page=2
and so on. if you need any further info, please let me know. cannot upload to server until i sort this problem out. thanks very much.
Reply With Quote  
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 643
Reputation: kkeith29 is on a distinguished road 
Rep Power: 3
Solved Threads: 72
kkeith29's Avatar
kkeith29 kkeith29 is online now Online
Practically a Master Poster

Re: pagination not displaying results

  #12  
Oct 20th, 2007
can you post the form that submits the chooser variable? i have to make a few changes to it and code and i think the problem will be solved
Reply With Quote  
Join Date: Jul 2005
Posts: 20
Reputation: ploppy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ploppy ploppy is offline Offline
Newbie Poster

Re: pagination not displaying results

  #13  
Oct 20th, 2007
here u go kkeith.

<!-- This defines a new form -->
<form action="data.php" method="post">

<!-- This creates the dropdown in html -->
<select name="chooser">

<option value="1">List #1</option>
<option value="2">List #2</option>
<option value="3">List #3</option>

</select>

<!-- Create a button -->
<input type="submit" value="Select" name="select">

</form> 

thank you
Reply With Quote  
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 643
Reputation: kkeith29 is on a distinguished road 
Rep Power: 3
Solved Threads: 72
kkeith29's Avatar
kkeith29 kkeith29 is online now Online
Practically a Master Poster

Re: pagination not displaying results

  #14  
Oct 20th, 2007
here is the form code:

<form action="data.php" method="get">
	<select name="chooser">
		<option value="1">List 1</option>
		<option value="2">List 2</option>
		<option value="3">List 3</option>
	</select>
	<input type="submit" value="Select" name="select">
</form>


here is the php code:

<?php

function ShowMyFiles() {

 

// vars global configuration

global $dbConn, $theme_path;

 

// vars messages

global $msg;

// vars template

global $error_msg, $status, $files, $owner, $test, $paginated;

 

if ($err) {

$error_msg = 'Custom error message';

}

 

if(!isset($_GET['page'])){

$page = 1;

} else {

$page = $_GET['page'];

}

  

// if something has been chosen


if (isset($_GET['chooser'])) {

// get the chosen value

$chooser = $_GET['chooser'];

 

// Define the number of results per page

$max_results = 10;

 

// Figure out the limit for the query based

// on the current page number.

$from = (($page * $max_results) - $max_results);

 

// get file listing

// if everything successful create query

// this selects all rows where the type is the one you chose in the dropdown

// * means that it will select all columns, ie name and type as i said above

 

$sql = "SELECT title, description, date FROM idx_reslink WHERE category_id='$chooser' LIMIT $from, $max_results";

$result = $dbConn->Execute($sql) or die(mysql_error());

 

 

// Figure out the total number of results in DB:

$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM idx_reslink WHERE category_id='$chooser'"),0);

 

 

// Figure out the total number of pages. Always round up using ceil()

$lastpage = ceil($total_results / $max_results);

 

 

 

global $paginated;

$paginated .= "<center>Select a Page<br />";

 

if ($page == 1) {

$paginated .= " FIRST PREV ";

} else {

$paginated .= " <a href='{$_SERVER['PHP_SELF']}?chooser=" . $chooser . "&page=1'>FIRST</a> ";

$prevpage = $page-1;

$paginated .= " <a href='{$_SERVER['PHP_SELF']}?chooser=" . $chooser . "&page=$prevpage'>PREV</a> ";

}

$paginated .= " ( Page $page of $lastpage ) ";

 

if ($page == $lastpage) {

$paginated .= " NEXT LAST ";

} else {

$nextpage = $page+1;

$paginated .= " <a href='{$_SERVER['PHP_SELF']}?chooser=" . $chooser . "&page=$nextpage'>NEXT</a> ";

$paginated .= " <a href='{$_SERVER['PHP_SELF']}?chooser=" . $chooser . "&page=$lastpage'>LAST</a> ";

}

 

$test = '';

for($i = 0;$i < $result->RecordCount(); $i++){

$file = $result->Fields("title");

$description = $result->Fields("description");

$date = $result->Fields("date");

 

$test .= '<table width="100%%" border="0">

<tr>

<td></td>

</tr>

</table>

 

<table cellpadding="2" cellspacing="1" border="0" align="center" width="100%" class="tbl_border_mem">

<tr class="tbl_caption_mem">

<td width="12%"><strong>Title</strong></td>

<td width="73%"><strong>Description</strong></td>

<td width="15%"><strong>Date Added</strong></td>

</tr>

<tr class="tbl_caption_mem">

<td valign="top">'.$file.'</td>

<td valign="top">'.$description.'</td>

<td valign="top">'.$date.'</td>

</tr>

</table> <br />';

 

$result->movenext();

}

}

$files = $test;

DisplayTemplate($theme_path . "cp/data.html", "\$files,\$paginated,\$error_msg");

}

 

/*===================================================

  main

  ===================================================*/

 

include "../application.php";

 

RunPreFilter(__FILE__);

 

ShowMyFiles();

 

RunPostFilter(__FILE__);

 

?> 

i cannot test this so i don't know if i made any stupid syntax errors. just let me know if there are any and i will fix them. i think the code will work but i am not for sure. i will keep trying until the problem is solved.
Reply With Quote  
Join Date: Jul 2005
Posts: 20
Reputation: ploppy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ploppy ploppy is offline Offline
Newbie Poster

Re: pagination not displaying results

  #15  
Oct 20th, 2007
dosen't display anything now kkeith. just 'there are no records'. thanks
Reply With Quote  
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 643
Reputation: kkeith29 is on a distinguished road 
Rep Power: 3
Solved Threads: 72
kkeith29's Avatar
kkeith29 kkeith29 is online now Online
Practically a Master Poster

Re: pagination not displaying results

  #16  
Oct 20th, 2007
what was the url after you submitted the form?
Reply With Quote  
Join Date: Jul 2005
Posts: 20
Reputation: ploppy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ploppy ploppy is offline Offline
Newbie Poster

Re: pagination not displaying results

  #17  
Oct 21st, 2007
kkeith. sorted now. wasn't posting the data to $nextpage. thank you evero so much for all your hard work and effort. very much appreciated. cheers
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 5:24 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC