Re: category with parentid

2012-05-30 Thread Tsubasa Tanaka
print " -",$i,"\n"; } } #--- regards, ts. tanaka// 2012/5/30 HaidarPesebe : > and also id (either cat or subcat) can be called > > - Original Message - From: "HaidarPesebe" > To: "MySQL Lists" > Sent: Wednesday, May 30, 201

Re: category with parentid

2012-05-30 Thread HaidarPesebe
and also id (either cat or subcat) can be called - Original Message - From: "HaidarPesebe" To: "MySQL Lists" Sent: Wednesday, May 30, 2012 2:31 PM Subject: Re: category with parentid Hello ts. Tanaka, I've tried your way and succeed. Thank you. But I wa

Re: category with parentid

2012-05-30 Thread HaidarPesebe
Hello ts. Tanaka, I've tried your way and succeed. Thank you. But I want to ask your help again what if the result will be like this: A. Cat A - Subcat A - Subcat A 2. CatB - Subcat B possible by using or which the previous result is Cat A - SubcatA, SubcatA Cat B - SubcatB

Re: category with parentid

2012-05-28 Thread Roberta Jask�lski
O, and the algorithm that I described only then works when the graph is cycle-free. Otherwise it forever runs. ** Scanned by MailScan AntiVirus and Content Security Software. Visit http://www.escanav.com for more info on eScan and X-Spa

Re: category with parentid

2012-05-28 Thread hsv
2012/05/28 12:54 +0700, HaidarPesebe select id,name from TABLE WHERE parentid='0' and a second call to the same table as this; select id,name from TABLE WHERE parentid='$id' (this $id is the result of calling the first call TABLE) Others have said, and I agree, you have a graph

Re: category with parentid

2012-05-28 Thread Tsubasa Tanaka
Hello Pesebe-san, how about this? SELECT t1.name AS cat, GROUP_CONCAT(t2.name) AS subcat FROM table AS t1 LEFT JOIN table AS t2 ON t1.id = t2.parentid WHERE t1.parentid = 0 GROUP BY cat; +---+---+ | cat | subcat| +---+---+ | cat A | subcat

Re: category with parentid

2012-05-27 Thread HaidarPesebe
Thanks for the information; I tried to call the database with something like this; select id,name from TABLE WHERE parentid='0' and a second call to the same table as this; select id,name from TABLE WHERE parentid='$id' (this $id is the result of calling the first call TABLE) and successful

Re: category with parentid

2012-05-25 Thread Roberta Jask�lski
2012/05/25 10:07 -0500, Andrés Tello You have a typical hierarchical data issue, can be solved with a graph. Theory review: http://www.algorithmist.com/index.php/Graph_data_structures Mysql and PHP implementation: http://www.phpro.org/tutorials/Managing-Hierarchical-Data-with-PHP-and-My

Re: category with parentid

2012-05-25 Thread Peter Brawley
On 2012-05-25 8:35 AM, h...@tbbs.net wrote: 2012/05/25 14:57 +0700, HaidarPesebe id | name | parentid -- 1 | cat A | 0 2 | cat B | 0 3 | subcat A | 1 4 | subcat A | 1 5 | subncat B | 2 - I want to display the result like this: 1. Cat

Re: category with parentid

2012-05-25 Thread Andrés Tello
You have a typical hierarchical data issue, can be solved with a graph. Theory review: http://www.algorithmist.com/index.php/Graph_data_structures Mysql and PHP implementation: http://www.phpro.org/tutorials/Managing-Hierarchical-Data-with-PHP-and-MySQL.html

Re: category with parentid

2012-05-25 Thread hsv
2012/05/25 14:57 +0700, HaidarPesebe id | name | parentid -- 1 | cat A | 0 2 | cat B | 0 3 | subcat A | 1 4 | subcat A | 1 5 | subncat B | 2 - I want to display the result like this: 1. Cat A - Subcat A - Subcat A 2. Ca

category with parentid

2012-05-25 Thread HaidarPesebe
I have a database for the category id | name | parentid -- 1 | cat A | 0 2 | cat B | 0 3 | subcat A | 1 4 | subcat A | 1 5 | subncat B | 2 - I want to display the result like this: 1. Cat A - Subcat A - Subcat A 2. CatB -