[eluser]dallen33[/eluser]
Code:
<? if ($ads_query->num_rows() > 0): ?>
<? foreach($ads_query->result() as $ads_row): ?>
<div style="border:1px solid black; padding:10px; margin-bottom:10px;">
<p><?=$ads_row->run_date?></p>
<p><?=$ads_row->notes?></p>
</div>
<? endforeach; ?>
<? endif; ?>
The code above works fine. I have a table called "ads" and a table called "clients". In "ads", a record can reference a client name by having the client ID. The "clients" table has the client name and ID. Simple stuff.
So how do I code this wisely? I want this record's client ID to show up as the client name. Before CodeIgniter, I'd do it like this:
Code:
$client_rslt = $mysqli->query("SELECT * FROM clients WHERE id = '" . $ad_row->client . "'");
$client_row = $client_rslt->fetch_object();
And then I'd show the result like this:
Code:
<?=$client_row->client?>
What's the best way of doing this in my code now that i'm using CodeIgniter. I've tried a few things but they seem clumsy. I'm very much a newb, so any help would be great