| Index
» Projekty
» phpMyEdit
» Fórum
» Drop Down list for displaying records |
 |
battonamunt
Založený: 09.12.2011
Príspevky: 4
Zaslal: 2011-12-09 17:16
Návrat hore
Odpovedať s citátom
|
I was wondering if there is a way to have a drop down list to change the number of fields shown. Could i replace the $opts['inc'] so that instead of a static record display i can have it changed by the user.
Thanks,
Andrew
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2011-12-10 15:02
Návrat hore
Odpovedať s citátom
|
| Kód: |
// On the fly, alter the number of records
// displayed in List mode
$num_recs = array(10,20,30,40,50);
if(array_key_exists('limit', $_REQUEST)){
$limit = intval($_REQUEST['limit']);
}else{
$limit = 10;
}
$opts['cgi']['persist'] = array('limit' => $limit);
$opts['inc'] = $limit;
// uncomment to use links instead of SELECT box
/*
$buffer = "\n".'<p>Records per page:<br>';
foreach($num_recs as $n){
$buffer .= "\n";
if($n == $limit){
$buffer .= $limit.' | ';
}else{
$buffer .= '<a href="'.basename($_SERVER['PHP_SELF']).'?limit='.$n.'">'.$n.'</a> | ';
}
}
$buffer = substr($buffer, 0, -3)."\n".'</p>';
echo $buffer;
*/
// SELECT box
$buffer = "\n".'<form name="myform1" action="hello" id="hello">';
$buffer .= "\n".'<select name="mylinks1" onchange="window.location=document.myform1.mylinks1.options[document.myform1.mylinks1.selectedIndex].value">';
$buffer .= "\n".'<option value="">'.$limit.' records displayed</option>';
foreach($num_recs as $n){
if((isset($limit) && $n == $limit) || (isset($_GET['limit']) && $n == $_GET['limit'])){
// no option
}else{
$buffer .= "\n".'<option value="'.basename($_SERVER['PHP_SELF']).'?limit='.$n.'">'.$n.'</option>';
}
}
$buffer .= '</select>';
$buffer .= '</form>';
$buffer .= isset($limit) ? '<p>Debug: value of $limit = '.$limit.'</p>' : '';
echo $buffer; |
|
battonamunt
Založený: 09.12.2011
Príspevky: 4
Zaslal: 2011-12-12 17:05
Návrat hore
Odpovedať s citátom
|
Thank you Doug. You're a life saver.
|
battonamunt
Založený: 09.12.2011
Príspevky: 4
Zaslal: 2011-12-12 17:08
Návrat hore
Odpovedať s citátom
|
The owner of my company wanted me to thank you again and tell you he loves the program and has purchased the export functionality (to give me more headaches im sure) and to help support the cause. great program!
Thanks, Andrew
|
|
Odoslať novú tému
Odpovedať na tému
|
|
|
|