The MySQL query:
SELECT title,alias,parent FROM '._prefix.'categories
WHERE (language = \''._language.'\' || language = \'all\')
&& status = \'published\'
ORDER BY rank ASC
The Result (from phpMyAdmin):
title | alias | parent
Home | home | 0
Todo | todo | 0
Multiuser| todo_mu | 21
Modulsys | todo_mod | 21
The PHP:
while($c = mysql_fetch_array($category_result)) {
if($c['parent'] == 0) {
$output .= '<li><a href="'._rewrite_string.$c['alias'].'" title="'.$c['title'].'">'.$c['title'].'</a>';
$output .= '<ul>';
mysql_data_seek($category_result,0);
while($d = mysql_fetch_array($category_result)) {
$output .= '<li class="space_left"><a href="'._rewrite_string.$c['alias'].'/'.$d['alias'].'" title="'.$d['title'].'">'.$d['title'].'</a>';
$output .= '</li>';
}
$output .= '</ul>';
$output .= '</li>';
}
}
This should generate a category list like that
cat 1
- subcat 1
- subcat 2
cat 2
cat 3
but it generates something like that
cat 1
- cat 1
- cat 2
- subcat 1
- subcat 2
using the mysql_fetch_array into another (nested) without using mysql_data_seek causes an abort once the nested mysql_fetch_array was called. it only outputs cat1 and nothing more.
please provide me the solution, thank you