Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- mysql_fetch_array and multitable queries
October 13, 2005, 2:09 pm
rate this thread
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
$row = mysql_fetch_array( $rs );
$vn = new venue();
$row['status.name'], /*HERE */
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
Re: mysql_fetch_array and multitable queries
are (or aren't getting). If you explicitly list out your columns you
can alias them and get to them that way:
FROM venues v, status s
WHERE s.status_id = v.fk_status_id
Here I called venue.name venue_name and status.name status_name. So in
your row, you can do $row['venue_name'] and $row['status_name'].