NYCPHP Meetup

NYPHP.org

[nycphp-talk] newbie question/confusion

Freeman, Joshua j at nybg.org
Tue Feb 22 23:10:22 EST 2005


This may be more of a MySQL question than a PHP question but here goes:

First, I will confess to the fact that I'm using PHAkt/AdoDB with Dreamweaver to help myself learn PHP... 
So, that is why the syntax is what it is. It's a place to start...  :-)


I have a small database with two tables in it.  It's a database of
Botanical Gardens in the US.

Table 1 contains the botanical gardens and has 8 fields:

(I'm abbreviating for brevity and clarity):  id, name, address, town,
state_id, zip, phone, url

Table 2 contains the states referred to in the 'state_id' field and
itself has 3 fields

id, abbreviation, name

So, 'id' in the 'state' table is linked to the 'gardens' table via
that table's 'state_id' field.

Now, in pulling data out of the database to display on a web page I
have all of my connection stuff working and the query of 'select *
from gardens' along with this php code:

 <td align="center"><?php echo $row_Recordset1['botgard_name']; ?></td>
   <td align="center"><?php echo $row_Recordset1['botgard_address']; ?></td>
   <td align="center"><?php echo $row_Recordset1['botgard_town']; ?></td>
   <td align="center"><?php echo $row_Recordset1['state_id']; ?></td>
   <td align="center"><?php echo $row_Recordset1['botgard_zip']; ?></td>
   <td align="center"><?php echo $row_Recordset1['botgard_phone']; ?></td>
   <td align="center"><?php echo $row_Recordset1['botgard_url']; ?></td>

works fine, pulling records out of the 'gardens' table and displaying
it on a web page, but, of course, I'm seeing the 'state_id' instead of
either the 'state_abbreviation' or the 'state_name'.

I am at a complete and total loss as to how to edit my code at this
point so that, before displaying anything, i can grab either
'state_abbr' or 'state_name' from the states table, properly
associated with the 'state_id' and display the actual state
abbreviation or state name in my web page.

I'm so close, yet so far.  I know if I can be shown once how this
works, I'll be able to apply the solution again in the future.

Thanks in advance for any help with this.

Sincerely,

Joshua






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20050222/cbe63780/attachment.html>


More information about the talk mailing list