Reply to Re: I have sub-categories but want to display full category path

Your name:

Reply:


Posted by Phil Latio on 02/05/07 15:04

> There's another (IMHO easier) way to avoid that: While running the
> queries collect all breadcrumb items in an array. After that reverse the
> array and just use implode() to print it out with '>>' separators. Also
> set error_reporting to E_ALL while developing - your code will throw
> some notices.
>
> Slightly modified, but untested:
>
> function breadcrumb($object) {
> $db = new MySQL("*****", "*****", "*****", "***");
> $db->connect();
> $db->select();
> $breadcrumb_array = array();
> while ($object > 0) {
> $db->query("
> SELECT category_name, parent_category_id
> FROM category
> WHERE category_id = $object"
> );
> $result = $db->fetchArray();
> $breadcrumb_array[] = $result['category_name'];
> $object = $result['parent_category_id'];
> }
> print implode(' >> ', array_reverse($breadcrumb_array));
> }

Thanks for this extra feedback. Always good to see other peoples ideas.

Not come across "array_reverse" before although "implode" sounds familiar
but not used that either. I will check them out.

Cheers

Phil

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация