•
•
•
•
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
![]() |
•
•
Join Date: Jul 2005
Posts: 20
Reputation:
Rep Power: 4
Solved Threads: 0
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:
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.
http://localhost/public_html/cp/data.php?page=2
•
•
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 643
Reputation:
Rep Power: 3
Solved Threads: 72
•
•
Join Date: Jul 2005
Posts: 20
Reputation:
Rep Power: 4
Solved Threads: 0
here u go kkeith.
thank you
<!-- 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
•
•
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 643
Reputation:
Rep Power: 3
Solved Threads: 72
here is the form code:
here is the php code:
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.
<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.
•
•
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 643
Reputation:
Rep Power: 3
Solved Threads: 72
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Clean Previous Next Script for MySQL results (PHP)
- pagination and search (PHP)
- Pagination - not displaying results properly, please help! (PHP)
Other Threads in the PHP Forum
- Previous Thread: PLease HELP(newsletter)
- Next Thread: PHP ?queries - How to?


Linear Mode