Welcome Guest, Not a member yet? Register   Sign In
Trying to figure out how to use db->where... does my code make sense?
#1

[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>&lt;?=$ads_row->run_date?&gt;</p>
    <p>&lt;?=$ads_row->notes?&gt;</p>
</div>

&lt;? endforeach; ?&gt;

&lt;? endif; ?&gt;

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:
&lt;?=$client_row->client?&gt;

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 Smile


Messages In This Thread
Trying to figure out how to use db->where... does my code make sense? - by El Forum - 10-01-2008, 12:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB