Veritabanımda iki sütun var, yılı ve içeriği yıllara göre gruplamak istiyorum (çok fazla içeriğim var ve yıllarca sadece 2015 ve 2016 değil) böylecePhp: sütundaki tüm içeriği çıktı sadece ilk öğe değil
) örnek i html
<div class="all">
<div class="2016">
2016
<div class="content_2016">
All the content of the column that is in the same ligne as 2016 in the database
</div>
</div>
<div class="2015">
2015
<div class="content_2015">
All the content of the column that is in the same ligne as 2015 in the database
</div>
</div>
</div>
<?php
\t $query = "SELECT * FROM publi where pub_type=0 order by pub_year DESC, pub_publi ";
\t $result = mysqli_query($connection, $query);
\t $previous =0;
\t while ($val = mysqli_fetch_array($result))
\t {
\t \t if ($previous <> $val['pub_year'])
\t \t {
\t \t \t $previous = $val['pub_year'];
\t \t \t $year = $previous;
\t \t echo '<button type="button" class="btn btn-info" data-toggle="collapse" data-target="#';
\t \t echo $year;
\t \t echo '">';
\t \t echo $year;
\t \t echo '</button>';
\t \t echo '<div id="';
\t \t echo $year;
\t \t echo '" class="collapse">';
\t \t \t $Temp = highlight("person1",$val['pub_publi'],"0000FF");
\t \t \t $Temp = highlight("person2",$Temp,"0000FF");
\t \t \t $Temp = highlight("person3",$Temp,"0000FF");
\t \t \t $Temp = highlight("person4",$Temp,"0000FF");
\t \t \t $Temp = highlight("person5",$Temp,"0000FF");
\t \t \t $Temp = highlight("person6",$Temp,"0000FF");
\t \t \t $Temp = highlight("person7",$Temp,"0000FF");
\t \t \t $Temp = highlight("person8",$Temp,"0000FF");
\t \t \t $Temp = highlight("person9",$Temp,"0000FF");
\t \t \t $Temp = highlight("person10",$Temp,"0000FF");
\t \t \t echo '<a target=blank href="http://www.test.com/query.f?term=' . $val['pub_pubmed'] . '";)><img border="0" src="img/test.gif" align=MIDDLE alt="Search in for ' . $val['pub_publi'] . '"></a>';
\t \t echo $Temp;
\t \t \t \t echo '</div>';
\t \t \t
\t \t \t \t \t }
\t \t \t
\t \t \t
\t \t \t \t }
?>
O ... yıllar
vb sağ
çıkış olanağı olduğunu ancak yalnızca her yılın ilk ligne gösterilmiyor her yıl için tüm içerik.
Farklı bir yıl için "if" öğesinin dışında _no_ kodu var, dolayısıyla, yalnızca bir önceki satırla karşılaştırıldığında yıl içinde yazdırılan içerik olacak. – klaar
ve çalışmasını sağlamak için ne yapabilirim? Teşekkür ederim – usethe23