I have a database where I store publications: publication ID, Authors (priority is considered) and Publication title
I am having trouble with the second foreach as I need a loop to generate authors' names before moving to the title. the query will bring the result fine like:
PID Authors TITLE
1 NAME1 TITLE1
1 NAME2 TITLE1
1 NAME3 TITLE1
2 NAME1 TITLE2
2 NAME2 TITLE2
2 NAME3 TITLE2
and so on
I want the end result to be:
1 NAME1, NAME2, NAME3 TITLE1
2 NAME1, NAME2, NAME3 TITLE2
here is my code:
foreach ($query->result() as $row)
{
echo $row->PID;
echo ": ";
foreach ($query->result() as $row)
{
echo $row->AUTHORS;
echo ", ";
}
echo $row->TITLE;
echo "<br>" . "<br>";
}