Witam.
Problem polega na tym iz nie wiem jak zrobić Menu drzewko. Nie mam problemu z wyświetleniem wynikow z bazy tylko z sortowaniem tak aby wygladało to tak:
Grupa 1
- Produkt 1
- Produkt 2
- Produkt 3
Grupa 2
- Produkt 1
- Produkt 2
- Produkt 3
itd...
Ilość pozycji i grup zależna jest od tego ile sie tego wprowadzi przez panel admina.
Także chodzi mi głownie jak to wyświetlić w takiej strukturze jak wyżej podałem.
Oto co posiadam:
Index.php
<?php
include('baza.php');
echo '<h2>Kategorie artykułów</h2>';
$result = mysql_query("SELECT * FROM articles_categories ORDER BY id ASC"); {
echo '<a href="cat.php?id='.$row['id'].'"><b>'.stripslashes($row['tytul']).'</b></a><br />'; }
?>
cat.php
<?php
include('baza.php');
$id = (int)$_GET['id'];
$result = mysql_query("SELECT * FROM articles_categories WHERE id='$id'");
$result = mysql_query("SELECT * FROM articles WHERE id_cat='$id' ORDER BY tytul ASC"); {
echo '<a href="art.php?id='.$row['id'].'"><b>'.stripslashes($row['tytul']).'</b></a> <!--('.date("d.m.Y, H:i", $row['data']).') --> <br />'; }
?>
art.php
<?php
include('baza.php');
$id = (int)$_GET['id'];
{
if(empty($nick) || empty($tresc)) $komunikat = 'Wpisz wszystkie pola!'; else
{
$query = "INSERT INTO `articles_comments` (`id_art`, `nick`, `tresc`, `data`) VALUES ('$id', '$nick', '$tresc', '$data')";
if(mysql_query($query)) $komunikat = 'Pomyslnie dodano komentarz!'; }
}
$result = mysql_query("SELECT * FROM articles WHERE id='$id'");
?>
I struktura bazy:
CREATE TABLE `articles` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_cat` int(11) NOT NULL,
`tytul` text NOT NULL,
`tresc` text NOT NULL,
`opis` text NOT NULL,
`data` int(11) NOT NULL,
`suma` int(11) NOT NULL,
`ocen` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM ;
CREATE TABLE `articles_categories` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`tytul` text NOT NULL,
`opis` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM ;
CREATE TABLE `articles_comments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_art` int(11) NOT NULL,
`nick` text NOT NULL,
`tresc` text NOT NULL,
`data` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM ;
Ten post edytował sebian 11.03.2010, 16:14:24