This is the advanced version, so improved, of the above function. Now the function list for each line all sections that are belongs to the same parent.
Hope to get some or any criticism, suggestion or improvement to this recursive php list menu items function.
PHP Code:
// axew3 - 19 Jul 2010
// last update: 07 Aug 2010
// info: this code is part of the w3images the gallery images plugin for WordPress
// the function is called inside a foreach construct
// that pass to the function related sections as argument
function w3_SectionsSubNames($sectionid)
{
global $wpdb, $w3images_sections_table, $PHP_SELF;
$purl0 = $PHP_SELF . "/wp-w3images.php?w3_sectionid=";
$getsubsections = $wpdb->get_results("SELECT sectionid, parentid, name FROM $w3images_sections_table WHERE parentid = '$sectionid' AND activated = 1 ORDER BY sectionid ASC");
$b = sizeof($getsubsections);
$c = 0;
foreach( $getsubsections as $getsubin ){
$c++;
if( $getsubin->sectionid == 1 ) { continue; }
echo "<small><a href=\"".$purl0.$getsubin->sectionid."\" title=\"".$getsubin->name."\">".$getsubin->name."</a></small> ";
if( $c == $b ){ echo "<br />"; }
$getsubde = $wpdb->get_results("SELECT sectionid, parentid, name FROM $w3images_sections_table WHERE parentid = '$getsubin->sectionid' AND activated = 1 ORDER BY sectionid ASC");
$d = sizeof($getsubde);
$e = 0;
foreach( $getsubde as $getsubdew ){
$e++;
echo "<small><a href=\"".$purl0.$getsubdew->sectionid."\" title=\"".$getsubdew->name."\">".$getsubdew->name."</a></small> ";
if( $d == $e ){ echo "<br />"; }
}
w3_SectionsSubNames($getsubdew->sectionid);
}
return;
}
as above: the function should be improved in the way to return an hyphen that need to be added once more
for any subsections lines if there are. Any help editing the above code to return this improved result for the function will be great!
Bookmarks