[eluser]bcarter[/eluser]
Hi guys
I have probably the biggest noob question going! I am trying to display some data I have pulled out of my database and I am almost bald with the frustration!
I can get it to work with a foreach loop but as I only want to display 1 record (I don't want to use a limit clause in my query). How do I display data without using the foreach loop?
Here's my code...
Model
Code:
class Update_model extends Model {
function Update_model() {
parent::Model();
}
function get_data($id) {
$q = $this->db->query("SELECT details.empName, details.contact, details.add1, details.add2, details.add3, details.town, details.postTown, details.county, details.postCode, details.tel, details.email, details.interestArea, details.linkAdviser, details.leadSource, details.lead_status, details.tps_date, details.employee_count, notes.notes
FROM details
LEFT JOIN notes ON ( details.id = notes.employer )
WHERE details.id = '$id'");
$info = $q->result();
return $info;
}
}
View
Code:
<table class="results_table">
<tr>
<td><label>Contact: </label></td>
<td><?php echo $info->contact ?></td>
</tr>
<table>
Controller
Code:
class Update extends Controller {
function Update() {
parent::Controller();
}
function index() {
$data['page_title'] = "Update Lead";
$this->load->library('form_validation');
$id = '34';
$this->load->model('Update_model');
$data['info'] = $this->Update_model->get_data($id);
$this->load->view('head', $data);
$this->load->view('update_view', $data);
}
}
Thanks for helping a noob!