[eluser]Unknown[/eluser]
I have this codes below, I just put values on get_data, so it will run. How can I make it that if I input something in the input box and after clicking the submit button it will display the contents based on the user input?Thanks.
view:
Code:
<html>
<head>
<style type="text/css">
body { background-color:#fff; margin:40px; font-family:Lucida Grande,Verdana,Sans-serif; font-size:14px; color:#4F5155; }
h1 { color:#444; background-color:transparent; border-bottom:1px solid #D0D0D0; font-size:16px; font-weight:bold; margin:24px 0 2px 0; padding:5px 0 6px 0; }
.box
{
margin-top:100px;
}
.mytable
{
color:red;
}
</style>
</head>
<body>
<div class="box">
<form action="table_view.php" method="post">
<input type="text" name="number">
<input type="submit" name="submit">
</form>
<?php $tmpl = array ( 'table_open' => '<table border="1" cellpadding="2" cellspacing="1" class="mytable">' );
$this->table->set_template($tmpl); ?>
<?php echo $this->table->generate($query2); ?>
</div>
</body>
</html>
model
Code:
<?php
class Model1 extends Model {
private $query3;
function Model1()
{
parent::Model();
}
function get_data($num)
{
$this->query3 = $this->db->query("SELECT * FROM truckinfo where plateno=".$num."");
return $this->query3;
}
}
?>
Controller
Code:
<?php
class Table extends Controller {
function Table()
{
parent::Controller();
}
function index()
{
$this->load->model('Model1');
$this->load->library('table');
$query['query2'] = $this->Model1->get_data(8271626);
$this->load->view('table_view',$query);
}
}
?>