LEFT JOIN data listing

I have 2 mysql tables
table “content” with rows “id” and “title”
and table "files
" with rows “filename” and “content”

I wanted the PHP to create a list of titles from the “content” table, and that, under each title, list of filenames from table “files”, if their “content” is the same number from the id number of a “title”.
Like this:

title1

  • filename1
  • filename2
  • filename3
    title2
  • filename4
  • filename5

I used LEFT JOIN and this function

$arr_results = array();

while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
    $arr_results[$row['title']][]=$row['filename'];
}

foreach($arr_results as $title=>$filenames)
{
    echo $title.'<br>';
    
    foreach($filenames as $filename)
    {
        echo '-'.$filename.'<br>';
    }    
}

recently I added “date” row into “files” table and now I need result like this
title1

  • filename1 - date1
  • filename2 - date2
  • filename3 - date3
    title2
  • filename4 - date4
  • filename5 - date5

Can somebody help me? Where and how should I insert “date” row into this function to get all work properly?


while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
    //$arr_results[$row['title']][]=$row['filename'];
    $arr_results[$row['title']][]=$row;
}

foreach($arr_results as $title=>$rows)
{
    echo $title.'<br>';
    
    foreach($rows as $row)
    {
        //$row['filename'] $row['foo'] etc...
    }    
}

thanx a million
you’re my hero of the week :slight_smile: