简体   繁体   中英

How to display the list from database using selected value in drop down

manage_bank

Hi everyone,

Can someone help me, How to display the bank name based on selected drop down, when we choose

for example:- 50 records

then it will display 50 records of the bank name from database.

When we logout the value still remain the same 50 records.

<?php
// Includes the required files
include ("../ecompany/terms_includes.php");
?>
<?php
// Check user authority for this page
$ModuleName = "Manage Banks";
$ModuleAction = "view";
base_checkAuthority($ModuleName,$ModuleAction)
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
include PATH_INC_HEAD;
?>
<?php
//get page number
$page = $_GET["page"];
$record = $_GET["record"];
//get Miscellaneous detail
$MiscellaneousDetail = base_getMiscellaneousDetail();
?>
<?php
if(!isset($page))
{
    $page = 1;
}
if(!isset($record))
{
    $record = $MiscellaneousDetail['base_mis_default'];
}

//go to reload page
if(isset($_POST['load']))
    {
        $page = 1;
        $record = $_POST['records_per_page'];
    }

//go to add profile page
if(isset($_POST['add']))
    {
        echo '<script type="text/javascript">' . "\n";
        echo 'window.location="../ecompany/add_bank.php";';
        echo '</script>';
    }

//go to home page
if(isset($_POST['cancel']))
    {
        echo '<script type="text/javascript">' . "\n";
        echo 'window.location="../terms_base/home.php";';
        echo '</script>';
    }
?>
</head>
<body>

<div class="container"> 
<?php
include PATH_INC_HEADER;
?>
<div class="main_body1">

<div id="update_category"></div>

<div style="width:800px; margin:auto">

<?php 
include PATH_INC_DESC;
?>
<div style="clear:both"></div>
<form name="bank_list_form" id="bank_list_form" method="post" action="">
<div style="width:800px; margin:auto; text-align:left">
 <select name="records_per_page" id="records_per_page"  >
 <option value="<?php echo $record; ?>">Default Records/Page :</option>
 <option value="1" title="1" >1</option>
 <option value="3" title="3" >3</option>
 <option value="5" title="5" >5</option>
 <option value="10" title="10" >10</option>
 <option value="20" title="20" >20</option>
 <option value="30" title="30" >30</option>
 <option value="50" title="50" >50</option>
 <option value="100" title="100" >100</option>
 <option value="200" title="200" >200</option>
 <option value="500" title="500" >500</option>
 <option value="1000" title="1000" >1000</option>
 </select>
  <input type="" size="4" style="width:25px" name="record"    

  id="record"value="<?php echo $record; ?>" readonly="readonly" />
  <div id="searchbutton">
  <input type="submit" id="load" name="load" value="Refresh">
  </div>
  </div>
 <table cellspacing="1" class="tablesorter">
 <thead>
    <tr>
        <th></th>
        <th>Code</th>
        <th>Name</th>
        <th>Description</th>
        <th>Remark</th>
        <th></th>
        <th></th>
    </tr>
 </thead>
 <tbody>
   <?php ecoy_listBank($page, $record) ?>
 </tbody>
   <tr>
        <td align="center" colspan="8"><input type="submit" id="add"       

  name="add" value="Add Bank" /><input type="submit" id="cancel"    
  name="cancel" value="Cancel" /></td>
   </tr>
  </tfoot>
  </table>
  </form>
  <br />
  </div>

    <div class="clearboth"></div>
  </div>
  <?php
  include PATH_INC_FOOTER;
  ?>

  </div>

  </body>
  </html>

Much appreciate, Thanks.

The title of your question is misleading. But if I got it right you actually succeed in querying your data correctly and refreshing the number of records with your refresh button.

You real question is how to persist the default value of the dropdown after a logout.

By mentioning your logout feature I assume you have users and a user table in your database.

From here you have two solutions I can think of:

1. Save the users preferences like the default value of your dropdown within your users table or create a separated table dedicated for this purpose.

2. Store users preferences in cookies

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM