Reply to mysql_fetch_array and multitable queries

Your name:

Reply:


Posted by thehuby on 10/13/05 17:09

I have a query that looks at two tables and pulls all the data back:

SELECT * FROM venues, status WHERE status_id = fk_status_id

I then have a class to hold the information I want. To initialise it I
get the data from the results set as per normal. The issue I have is
that two fields have the field name 'name'. In SQL terms I would refer
to them like 'tablename.columnname'. How do I achieve this using a
mysql fetch array?

The code I am using below brings back empty/null items for the
'tablename.columnname'.

$row = mysql_fetch_array( $rs );
$vn = new venue();
$vn->params_init( $row['venue_id'],
$row['venues.name'], /*HERE*/
$row['address1'],
$row['address2'],
$row['address3'],
$row['town_city'],
$row['county'],
$row['postcode'],
$row['other_details'],
$row['url'],
$row['status.name'], /*HERE */
$row['copy_of_id']
);

In this instance I am developing the database so I can get round it by
changing the field names, but in the future I may not be able to.

If possible I want to avoid using two queries to get the information I
require.

Regards,

Rick Huby
www.e-connected.com

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация