Hi there,
I am using following script to print data from a database:
//QUERY
<?php
try {
$query_sql = 'SELECT article_name, author_name, lang_name FROM article
INNER JOIN author
ON article.author_id = author.id
inner join lookuplang
on article.id = lookuplang.articleID
inner join lang
on langID = lang.id
ORDER BY article.id ASC';
$result = $GLOBALS['pdo']->query($query_sql);
}
//DISPLAY RECORDS
foreach($result as $row) {
$valori[] = array('article_name'=>$row['article_name'],'author_name'=>$row['author_name'], 'lang_name'=>$row['lang_name']);
}
include 'test.html.php';
?>
<?php foreach($valori as $lista):?>
<?php
$lingua = $lista['lang_name'] . ': Status';
?>
<tr>
<td> <?php echo $lista['article_name']?></td>
<td> <?php echo $lista['lang_name']?></td>
</tr>
<?php endforeach?></table>
I would like to display the values like this:
Article
Lang A
Lang B
Lang C
Lang D
First article
English
Italian
German
French
Second article
English
Italian
German
French
Tha main table is denominated article. The languages are contained in the table lang and the languages are related to the articles using a lookup ‘lookuplang’.
Thanks