[eluser]Unknown[/eluser]
Appologies in advance. I really need some help with a very simple search form which for the life of me I can not get to work.
I want to ask the user for a certificate number ......
say it is '12345678'
I can not find an example anywhere that shows me how to search for the input'ed value pass it on to the controller and view the results, god knows I have looked everywhere!. I know it am missing something really simple but for the life of me I can not spot the issue.
My Form looks like this
<html>
<head>
<title>Find a Certificate Number</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<?php echo validation_errors(); ?>
<?php echo form_open('certsfound'); ?>
<p>Certificate Number</p>
<input type='text' name='searchstring' value="" size="50" />
<p><input type="submit" value="Submit" /></p>
</form>
</body>
</html>
Not laugh .... but my controller looks like
<?php
class Find extends Controller {
function index()
{
$this->load->view('findcert');
}
function getAll() {
$this->db->select('id', 'cert_number', 'orig_timestamp');
$this->db->from('cins_cert_numbers');
$this->db->where('cert_number', 'searchstring');
$this->load->view('certsfound');
$q = $this->db->get();
if($q->num_rows() > 0) {
foreach ($q->result() as $row) {
$data[] = $row;
}
return $data;
}
}
}
the resulting view is certsfound.php
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div id="container">
<h1>List of Programs</h1>
<?php foreach($rows as $r) : ?>
<p><?php echo $r->id; ?></p>
<p><?php echo $r->cert_number; ?></p>
<p><?php echo $r->orig_timestamp; ?></p>
<?php endforeach; ?>
</div>
</body>
</html>
Forgive my ignorance, I believe that I am not passing the submit value user enters 'searchstring' correctly
cheers
Bruce