MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:jsf Date:February 23 2005 4:08am
Subject:newbie question
View as plain text  
This may be more of a PHP question than a MySQL question but here goes:

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
Thread
newbie questionjsf23 Feb
  • RE: newbie questionPete Moran23 Feb
RE: newbie questionTom Crimmins23 Feb