Jump to content
php.lv forumi

Php + mysql = menu


Agnisr

Recommended Posts

Sveika tauta, vajag bik uzlabot menu. Paslaik taats ir ar principu:

 

Kategorija

+apakskategorija

+apakskategorija

+apakskategorija

Kategorija2

+apakskategorija

+apakskategorija

+apakskategorija

 

Viss tiek izvadiits uzreiz, bet vajag taa lai apakskategorija atveertos tikai peec tam, kad ir uzklikskinaats uz kategorijas.

Kaadas idejas?

pagaidaam izvadu saadi

<?php
$db = mysql_connect("localhost");
mysql_select_db("xxx", $db);
$sql = "Select p1.id, p1.title AS title1 , p2.cat, p2.title AS title2 from ad2_gallery_cats AS p1 INNER JOIN ad2_gallery AS p2 
on p1.id = p2.cat AND p1.cat != 0  ORDER BY title1, title2";
$res = mysql_query($sql, $db);
echo '<h1>Modelu galerija</h1>';
$last_main_title = '';
while($row = mysql_fetch_assoc($res)) {
if ($last_main_title != $row['title1']) {
echo '<li><a href="">'.$row['title1'].'</a></li>';
echo '<p><a href="">'.$row['title2'].'</a></p>';
$last_main_title = $row['title1'];
} else {
echo '<p><a href="">'.$row['title2'].'</a></p>';
}
}
?>

 

Var teikt, ka esmu iesaaceejs, plzz pastaastiet ar kaadiem paneemieniem to vareetu piedabuut gatavu! Paldies

Link to comment
Share on other sites

×
×
  • Create New...