|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Queston regarding printing back the results of an SQL query
I have kind of a simple queston. If you have an SQL query that looks at multiple tables, then you put the results of that query in an array, what are the names in the array? I'm bad at explaining things, so basicly I have this.. Basicly I'm wondering because like, since in SQL you can reference with table_name.field_name.. then what happens if you have a field called ID in both tables? $row[ID] can't be both of them can it? Basicly that's my queston, sorry if its wordy for being so simple. |
|
#2
|
|||
|
|||
|
RE: Queston regarding printing back the results of an SQL query
|
|
#3
|
|||
|
|||
|
RE: Queston regarding printing back the results of an SQL query
what happens (i think) is that clashing names will wind up being "table1.field" and "table2.field" instead of just "field"
try going print_r($row); to make certain.. |
|
#4
|
|||
|
|||
|
RE: Queston regarding printing back the results of an SQL query
no, that is not what happens. associative arrays returned from mysql_fetch_* function always use only column name for array key.
when u use mysql_fetch_rows(), every column from first table is returned as an offset in array (ie 0..3) and every column from second table is returned also as offset, but starting where first ended (ie 4..9). when u use mysql_fetch_assoc() table columns are returned as column_name=>column_value pairs, and since php allows only one value per one key in array, later columns with same name (ie table2.id, going as "id")will override first ones (ie table2.id going also as "id"). but when u use mysql_fetch_array() result is mix from previous two, so there are all columns with offsets (0..3 and 4..9), but only one instance of doubled coulumns (ie "id)... |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Queston regarding printing back the results of an SQL query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|