View Single Post
06-04-2012, 04:17 PM
#8
Dan is offline Dan
Dan's Avatar
Status: Request a custom title
Join date: Feb 2005
Location:
Expertise:
Software:
 
Posts: 3,164
iTrader: 15 / 86%
 

Dan is an unknown quantity at this point

  Old

In case anyone wonders why printing array of a joined table duplicates the data: http://stackoverflow.com/questions/4...ned-join-array

Anyway, if I have two tables joining together with identical coloumn names (in this case ID.) The array prints the second ID as a number, so I have to use $topic['10'];

For example

PHP Code:
    [0] => 3
    
[id] => 12
    
[1] => 2
    
[category] => 2
    
[2] => Sample Post Title
    
[title] => Sample Post Title
    
[3] => Let's see if the favourite/save star icon shows up yellow or hidden and grey.
    [text] => Let'
s see if the favourite/save star icon shows up yellow or hidden and grey.
    [
4] => 
    [
revised] => 
    [
5] => 
    [
locked] => 
    [
6] => 0
    
[replies] => 0
    
[7] => 2012-06-03 13:45:40
    
[date] => 2012-06-03 13:45:40
    
[8] => abracadabra
    
[username] => abracadabra
    
[9] => 1
    
[role] => 1
    
[10] => 12 
PHP Code:
SELECT topics.idtopics.categorytopics.titletopics.texttopics.revisedtopics.lockedtopics.repliestopics.dateusers.usernameusers.roleusers.id 
FROM 
`forum topicstopics
LEFT JOIN users ON users
.id topics.author
WHERE slug
='{$slug}' 
Am I doing it wrong?

Reply With Quote