Output displays ID instead of text entry

I am creating a jobs database and I’m trying to code the output. Instead of seeing “TX” for a state, I’m seeing it’s ID value of “1”

What code Do I need to script in order to display it’s value and not the ID?

Here is the table setup:

Table 1: _state
Row1: ID INT AUTOINCREMENT
Row2: State VARCHAR

Table 2: _city
Row1: ID INT AUTOINC
Row2: StateID INT
Row3: City

Table 3: _jobs
Row1: ID INT AUTOINC
Row2: CityID INT
Row3: StateID INT
Row4: Job Title VARCHAR

Here’s the php code, data is being taken from table 3 _jobs:

<?php echo $row_Recordset1['City']; ?> <?php echo $row_Recordset1['State']; ?> <?php echo $row_Recordset1['Job Title']; ?>

My output looks like this:

City State Job Title
1 1 Test Job 1

How are you populating $row_Recordset1 ?

What’s the query? How do you parse that data. I think we need to see more of the code.

I’m using mysql to populate the database. Is this what you’re asking?

We’d like to see some more of the code that you use in order to display the data.

I realized that you were using a database such as MySQL, however, what is the query that you are using to return the data from the database.

When you query the database, WHAT do you do with the results. (i.e. how are you parsing it).

Typically the flow goes something like:

  1. Connect to the database server (mysql_connect )
  2. Select the database (mysql_select_db)
  3. Query the database (mysql_query)
    • Alternatively you could combine 2 and 3 into mysql_db_query - -
  1. Return the results and assign it to a variable (array)
  • a. mysql_ fetch_ array
  • b. mysql_ fetch_ assoc
  • c. mysql_ fetch_ field
  • d. mysql_ fetch_ lengths
  • e. mysql_ fetch_ object
  • f. mysql_ fetch_ row
  1. Manipulate/present “Fetched” Results (echo, print, trim, etc…)

Mysql_query will return a result set resource, and a variable stored with such a resource will return false when tested with is_array() and true when tested with is_resource(). After applying mysql_fetch_array() (or _row or _assoc) an array is returned :wink: Just wanted to point that out.

Sponsor our Newsletter | Privacy Policy | Terms of Service