[eluser]Fielder[/eluser]
Am I running this query and passing the results into my view correct?
Code:
$data['results'] = $this->Businesses->getBusiness($bus_number);
//load database query results into array for the input form
foreach ($data['results'] as $row)
{
$data['bus_name'] = $row['bus_name'];
$data['bus_number'] = $row['bus_number'];
$data['bus_address'] = $row['bus_address'];
$data['bus_city'] = $row['bus_city'];
$data['bus_state'] = $row['bus_state'];
$data['bus_zip'] = $row['bus_zip'];
$data['bus_contact'] = $row['bus_contact'];
$data['bus_phone'] = $row['bus_phone'];
$data['bus_mobile'] = $row['bus_mobile'];
$data['bus_fax'] = $row['bus_fax'];
$data['bus_email'] = $row['bus_email'];
$data['cat_id'] = $row['cat_id'];
$data['bus_corporate'] = $row['bus_corporate'];
$data['user_rep'] = $row['user_rep'];
}
$this->load->view('include/header.php', $data);
$this->load->view('business_new',$data);
then in the view I'm inserting the individual variables into the "value" part of their corresponding input boxes...
Code:
<li>
<label for="bus_name">Business Name</label>
<em>*</em><input type="text" name="bus_name" size="36" value="<?= $bus_name; ?>" class="required" />
</li>
<li>
<label for="bus_number">Business Number</label>
<em>*</em><input type="text" name="bus_number" size="24" value="<?= $bus_number; ?>" class="required" />
</li>
etc..
etc..
etc..
Seems that my foreach statement is looping through that entire array for every result returned from the model(I don't know). But I would like to know if I could improve upon this code to efficiently and with less typing pass and display the results in the input boxes. Thx.