Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Duplicate fields in returned data

Status
Not open for further replies.

MrBelfry

IS-IT--Management
Joined
May 21, 2003
Messages
289
I have a sql statement that is returning data from 2 different tables (news_item & user). Unfortunately both tables have an ID field. Normally i put the data into a variable using a while loop like:
Code:
while ($row = mysql_fetch_array($result))
 {
  $story[$count]["id"] = $row["id"];	
  $count++;
  }
BUT $row["id"] always refers to the second 'id' value (which I get from the user table). How can I refer to the id value from the news_item table?

Thanks in advance

MrBelfry
 
select news_item.id from ....

Known is handfull, Unknown is worldfull
 
Doesn't matter I used an alias

MrBelfry
 
If you supply the actual SQL query string we'll be able to help you. We can't guess what alias you used...
 
I was being stupid and keep forgetting I've got a copy of the PHP manual on my desktop!

There wasn't a problem with mysql string per se (i would have posted the problem in that forum if it was) but a problem with the mysql_fetch_array. I obviously didn't articulate my problem clearly enough. I was basically asking about duplicate indexes in the array that is returned by the mysql_fetch_array function.

I initially solved the problem by using an alias in my sql string. I've revised the solution by using a numeric index to reference the array instead.


MrBelfry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top