I need to extract and display some info from my database. My problem is: the column 'fatura'(in table A) always will be linked to multiples 'stur' rows (in table B). I can't find how to not display the same 'fatura' for each 'stur'.
My code:
<?php
$mysqli = NEW MySQLi('localhost','root','','server');
$sqlFatura = $mysqli->query("SELECT fatura,stur
FROM faturas inner join anexos
WHERE ID_fatura = FK_fatura
");
if($sqlFatura->num_rows > 0){
while($rows = $sqlFatura->fetch_assoc()){
$fatura = $rows['fatura'];
$stur = $rows['stur'];
echo "<p> Fatura $fatura => Stur: $stur </p>";
?>
Result right now:
'Fatura FT01 => Stur 01
Fatura FT01 => Stur 02
Fatura FT01 => Stur 03
Fatura FT02 => Stur 04
Fatura FT02 => Stur 05'
Need to be :
'Fatura FT01 => Stur 01, 02, 03
Fatura FT02 => Stur 04, 05
Any suggestions are welcome.
Thanks in advance!
sturcolumn contain? show one or two of such data