Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.