Problem with Search Function with codeigniter - El Forum - 04-01-2009
[eluser]Unknown[/eluser]
Hi Guys,
I have a question to you I have a problem how to get value of my dropdown in a my code with a press drop down Account Number and type the account number and press the button search i will get the result of the following number see my attachment
code for controller/customer.php
Code: function search()
{
$this->load->view('/cust/display');
}
function search_id()
{
$custid = (strlen($this->uri->segment(3))>0) ? ($this->uri->segment(3)) : ($this->input->post('account_number'));
//echo "id ".$custid;
//$data['query'] = $this->customer_model->querybyid($custid);
//$datax = $this->customer_model->querybyid($custid);
/*$qry = 'SELECT b.cf_454,
b.cf_456,
b.cf_450,
b.cf_452,
b.cf_458,
c.survey_id,
c.lastname,
c.firstname
FROM survey_accounts a LEFT OUTER JOIN vtiger_accountscf b
ON b.accountid = a.account_id LEFT OUTER JOIN households c
ON a.survey_id = c.survey_id
WHERE b.cf_452 = "'.$custid.'"';*/
$qry = "SELECT
b.cf_454,
b.cf_450,
b.cf_452,
b.cf_456,
b.accountid,
a.rcpt_lname,
a.rcpt_fname,
a.rcpt_mi,
a.survey_id,
a.completed,
a.date_completed,
a.survey_date
FROM survey_accounts a, vtiger_accountscf b
WHERE b.cf_452 = a.account_number
and a.account_number = '$custid'";
$data['query'] = $this->db->query($qry);
//echo $this->db->last_query();
if(strlen($custid)>0) {
if ($data['query']->num_rows()>0) {
$data['myvar'] = '';
$this->load->view('cust/GetCustomerData',$data);
} else {
$this->db->where('cf_452',$custid);
$myquery = $this->db->get('vtiger_accountscf');
if ($myquery->num_rows()>0) {
redirect('customer_survey/add/'.$custid);
} else {
$data['myvar'] = '1';
$this->load->view('cust/display.php',$data);
//redirect('customer/index');
}
}
} else {
redirect('customer/index');
}
}
code for model/customer.php
Code: function querybyid($custid)
{
$query = 'SELECT a.cf_454,
a.cf_456,
a.cf_452,
a.cf_458,
c.survey_id,
c.lastname
FROM vtiger_accountscf a LEFT OUTER JOIN survey_accounts b
ON b.account_id = a.accountid LEFT OUTER JOIN households c
ON b.survey_id = c.survey_id
WHERE a.cf_452 = "'.$custid.'"';
return $this->db->query($query);
}
code for views/display.php
Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Customer Account Information</title>
</head>
<body>
<center>
<form method="POST" action="<?php echo base_url() ?>index.php/customer/search_id" name="form1">
<p><b>Enter Customer Account Number to Retrieve Information:</p></b>
<p align="center"><strong>Select Your Choices </p></strong>
<div align="center">
<select name="dropdown">
<option value="cf-452">Account Number</option>
<option value="cf_454">Customer Subscriber Name</option>
</select>
<p align="center"><IMG alt="Sky" width="84" height="49" align="center" border="0"></p>
<p><b>Customer Account Number:</b> <input type="text" name="account_number" />
<?php
if (strlen($myvar)>0) {
echo "<font color='red'><strong>No records founds. Try another search criteria.</font></strong>";
}
?>
</p>
<p><input type="submit" value="Search Account Number" /></p>
</form>
Code for views/GetCustomerData.php
Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Customer Account Information</title>
</head>
<body>
<center>
<form method="POST" action="<?php echo base_url() ?>index.php/customer/search_id" name="form1">
<p><b>Enter Customer Account Number to Retrieve Information:</p></b>
<p align="center"><strong>Select Your Choices </p></strong>
<div align="center">
<select name="dropdown">
<option value="cf-452">Account Number</option>
<option value="cf_454">Customer Subscriber Name</option>
</select>
<p align="center"><IMG alt="Sky" width="84" height="49" align="center" border="0"></p>
<p><b>Customer Account Number:</b> <input type="text" name="account_number" />
<?php
if (strlen($myvar)>0) {
echo "<font color='red'><strong>No records founds. Try another search criteria.</font></strong>";
}
?>
</p>
<p><input type="submit" value="Search Account Number" /></p>
</form>
Hoping for your kind help and consinderation.
Thanks
|