lbss

lbss

Joined
May 02, 2010

Activity Stream

lbss commented on a Page, Building a Parent/Child Category Structure  -  May 02, 2010

i have ommitted by db information above. you will have to fill in your own info for the vars below

$dbhost = "";
$dbuname = "";
$dbpword = "";
$dbname = "";

 Respond  
lbss commented on a Page, Building a Parent/Child Category Structure  -  May 02, 2010

I realise its a while since the last post but i got it working fairly easily.

I replaced -

"$query = "
select
*
from
categories
order by
cat_id
";

$result = $db->sql_query($query);

while($category = $db->sql_fetchrow($result))
{
"
with -

"$query = "
select
*
from
categories
order by
cat_id
";

$result = mysql_query($query);

while($category = @mysql_fetch_assoc($result))
{
"

My db connection is as follows;

"$dbhost = "";
$dbuname = "";
$dbpword = "";
$dbname = "";

$client_flags = 128;
$dbconnection = mysql_connect($dbhost, $dbuname, $dbpword, FALSE, $client_flags) or die("Connection Failure to Database");
mysql_select_db($dbname, $dbconnection) or die ("Database not found.");
"

I can then print_r on both arrays an get the following

print_r($cat_list);

with my sample data outputs:

Array ( [0] => category_item Object ( [cat_id] => 32 [depth] => 0 [cat_title] => Home Page (sample) [cat_parent_id] => 0 [cat_long_title] => Home Page (sample) ) [1] => category_item Object ( [cat_id] => 33 [depth] => 1 [cat_title] => test [cat_parent_id] => 32 [cat_long_title] => Home Page (sample) > test ) [2] => category_item Object ( [cat_id] => 34 [depth] => 0 [cat_title] => test2 [cat_parent_id] => 0 [cat_long_title] => test2 ) )

and print_r($cat_tree);

with my sample data outputs:

Array ( [32] => Array ( [cat_id] => 32 [cat_parent_id] => 0 [cat_title] => Home Page (sample) [home] => 0 [children] => Array ( [33] => Array ( [cat_id] => 33 [cat_parent_id] => 32 [cat_title] => test [home] => 0 [children] => Array ( ) ) ) ) [34] => Array ( [cat_id] => 34 [cat_parent_id] => 0 [cat_title] => test2 [home] => 0 [children] => Array ( ) ) )

What id like to know is how can I translate this into an

tree style menu and a 'ROOT / Home Page (sample) / test' breadcrumb syle list ?
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.