Jump to content

[SOLVED] Simple SQL query question


play_

Recommended Posts

i have this query

 

select
projects.id,
projects.type,
projects.title,
projects.url,
uploads.filename
from projects
inner join uploads on uploads.projectID = projects.id
where projects.type = 'lab'"

 

as you can tell it pulls info from projects and uploads table.

 

here's what uploads table look like

uoloadstbl.jpg

 

So both entries relate to the same project.

 

this is what the query returns

 

$result = $sql->query($query);
$row = $result->fetchAll(PDO::FETCH_NUM);


Array
(
    [0] => Array
        (
            [0] => 1
            [1] => lab
            [2] => SBR
            [3] => http://sbr.9leaves.com
            [4] => 847587269-sbr_1.0__(1).jpg
        )

    [1] => Array
        (
            [0] => 1
            [1] => lab
            [2] => SBR
            [3] => http://sbr.9leaves.com
            [4] => 1273681671-sbr_1.0__(2).jpg
        )

)

 

it returns 2 sets of results. how can i combine it into one? basically the result array would have 6 elements, the 6th one being the second(or first) screenshot image.... idea result would look like

 

Array
(
    [0] => Array
        (
            [0] => 1
            [1] => lab
            [2] => SBR
            [3] => http://sbr.9leaves.com
            [4] => 847587269-sbr_1.0__(1).jpg
            [5] => 1273681671-sbr_1.0__(2).jpg
        )

)

Link to comment
https://forums.phpfreaks.com/topic/180644-solved-simple-sql-query-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.