![]() | |||||||
join query, how to output? Hi all, i have this query i need to echo out all the contents in a loop: Code:
Although my while loop using a mysql_fetch_array gives this error: What is the correct way to loop through the data of a joined sql statement? And then echo it out? |
aliases I see you resolved this but just in case someone else wants to know... When you use a join query in PHP you have to alias the column names example: SELECT n.poster_id AS Poster_ID, n.date AS Date_Whatever, n.subject AS Subject, n.post AS Post, You can then reference your columns in your PHP code by using the aliases PHP Code: If you resolved the issue some other way please share. Thanks |
Not necessarily. You'd only really need to alias if you're selecting/using columns from both tables, that are the same. Eg: if you need to use 'username', but you're SELECT'ing the 'username' field from both tables. This could have been resolved with: Code:
OR Code:
|
Thanks for the replies and yes it is not needed to give each field a name unless they have the same name. |
| All times are GMT -7. The time now is 11:38 PM. |
Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0