List:General Discussion« Previous MessageNext Message »
From:Tsubasa Tanaka Date:May 30 2012 2:30pm
Subject:Re: category with parentid
View as plain text  
Pesebe-san,

I'm sorry to i'm not clear what do you want to do.
do you mean like this? (exampled by Perl)

#---
use DBI;

$cn = DBI->connect("DBI:mysql:test","root","");
$st = $cn->prepare("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;");
$st->execute;
while ($rs = $st->fetchrow_hashref) {
        print $rs->{cat},"<br>\n";
        @buff = split(/,/,$rs->{subcat});
        foreach $i (@buff) {
                print " -",$i,"<br>\n";
        }
}
#---

regards,


ts. tanaka//

2012/5/30 HaidarPesebe <haidarpesebe@stripped>:
> and also id (either cat or subcat) can be called
>
> ----- Original Message ----- From: "HaidarPesebe" <haidarpesebe@stripped>
> To: "MySQL Lists" <mysql@stripped>
> 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 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 <br> or <div>
>>
>> which the previous result is
>> Cat A - SubcatA, SubcatA
>> Cat B - SubcatB
>>
>> thank you
>>
>> __________ Information from ESET NOD32 Antivirus, version of virus
>> signature database 7179 (20120529) __________
>>
>> The message was checked by ESET NOD32 Antivirus.
>>
>> http://www.eset.com
>>
>>
>>
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus signature
> database 7179 (20120529) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql
>
Thread
category with parentidHaidarPesebe25 May
  • Re: category with parentidhsv25 May
    • Re: category with parentidAndrĂ©s Tello25 May
      • Re: category with parentidhsv26 May
    • Re: category with parentidPeter Brawley25 May
  • Re: category with parentidHaidarPesebe28 May
    • Re: category with parentidTsubasa Tanaka28 May
    • Re: category with parentidhsv28 May
    • Re: category with parentidhsv28 May
Re: category with parentidHaidarPesebe30 May
Re: category with parentidHaidarPesebe30 May
  • Re: category with parentidTsubasa Tanaka30 May