Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14343

Show chosen database on an another page after option is selected

$
0
0
I want to show a certain table from a selected database. How do I do that?

View for the dropdown where you can choose the database:
PHP Code:
<select name="klanten" class="dropdown-menu" onchange="this.form.submit()"
 
       <?php foreach($klanten as $row){ ?>
        <option value="<?php echo $row->klantnaam;?>"> 
        <?php echo $row->klantnaam?></option> 
        <?php ?>
    </select> 

Model (function for the dropdown)
PHP Code:
public function verversBelbestand(){

        
$search $this->input->post('klanten');

        
$dropdown_data['search'] = $search;

        
$query $this->db->query("SELECT DISTINCT databasenaam FROM project WHERE klantnaam in ('$search') ");
        
        
$databasenaam $query->row();

        if(
$query->num_rows() > 0)
        {
            return 
$databasenaam->databasenaam;
        } else {
            return (
'A database name');
        }

    } 

But after the chosen database I have a button under the table which leads to another page and wil show you some more data about the chosen database. But the problem is: It shows the "A database name" when it should be showing the chosen database


Model (The data which must be shown but doesn't show the chosen database)
PHP Code:
public function terugbel(){

 
       $database $this->verversBelbestand();
 
       if($database == null){
 
       $database $database;
 
       } else {

 
       $config['hostname'] = 'secret';
 
       $config['username'] = 'secret';
 
       $config['password'] = 'secret';
 
       $config['database'] = $database;
 
       $config['dbdriver'] = 'sqlsrv';
 
       $config['dbprefix'] = '';
 
       $config['pconnect'] = TRUE;
 
       $config['db_debug'] = TRUE;
 
       $config['cache_on'] = FALSE;
 
       $config['cachedir'] = '';
 
       $config['char_set'] = 'utf8';
 
       $config['dbcollat'] = 'utf8_general_ci';

 
       $this->db $this->load->database($configtrue);

 
       $this->load->library('table');


 
       $this->table->set_heading('Agent','Terugbeldatum''Terugbeltijd');

 
       $query1 $this->db->query("SELECT DISTINCT Agent, GETDATE() Terugbeldatum, Terugbeltijd FROM belbestand WHERE eindecode = 31 ORDER BY Terugbeldatum");

 
       $template = array(
 
       'table_open'            => '<table border="1" cellpadding="4" cellspacing="0">',

 
       'thead_open'            => '<thead>',
 
       'thead_close'           => '</thead>',

 
       'heading_row_start'     => '<tr>',
 
       'heading_row_end'       => '</tr>',
 
       'heading_cell_start'    => '<th>',
 
       'heading_cell_end'      => '</th>',

 
       'tbody_open'            => '<tbody>',
 
       'tbody_close'           => '</tbody>',

 
       'row_start'             => '<tr>',
 
       'row_end'               => '</tr>',
 
       'cell_start'            => '<td>',
 
       'cell_end'              => '</td>',

 
       'row_alt_start'         => '<tr>',
 
       'row_alt_end'           => '</tr>',
 
       'cell_alt_start'        => '<td>',
 
       'cell_alt_end'          => '</td>',

 
       'table_close'           => '</table>'
 
           );

 
   $this->table->set_template($template);     
    return $this
->table->generate($query1);
 
   
}


Viewing all articles
Browse latest Browse all 14343

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>