Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: Re: Tough question,corrections To Bill and Nik diregard previous post


Message #1 by "jorge" <jorge@d...> on Sun, 13 Oct 2002 09:00:12 -0500
If you can wait about 30 minutes I am just making a 
working version of this that has a slightly different 
take on those offered so far. 

Will post code in about 30 mins..

Best,
Justin :)

> -----Original Message-----
> From: jorge [mailto:jorge@d...]
> Sent: 13 October 2002 15:00
> To: professional php
> Subject: [pro_php] Re: Tough question,corrections To Bill and Nik
> diregard previous post
> 
> 
> Hi Bill &Nik
> I forgot to erase the COUNT(categoy) out of my prevous answer 
> and some other
> stuff  ( I was just going to make an example with the extra 
> table but i
> didnt) .
> please discard previous post
> This answer is SUPPOSED TO WORK with the ACTUAL TABLES that bill HAVE
> so my post should be like this
> 
>  $query=mysql_query("SELECT t1.category, 
> t2.myvar_x,t3.myvar_y,....... FROM
> category AS t1,mytable2 AS
> t2, mytable3 AS t3,..... WHERE t1.category= t2.myvar_x AND
> t1.category= t3.category ORDER BY
> t1.category ASC");
> 
>  //then make them arrays again
>  while($results=mysql_fetch_array($query))
>     {
> >     $category[]=$results["category"];
> >     $myvar_x[]=...............
> >     $....
> >     }
> > //in this case we dont count the elementes of the array is useless
> > //this is to start the counter that we will use to loop 
> through the array:
> > $i=0;
> > foreach ($category AS $key)
> >     {
> >         switch($key)
> >             {
> >             case "my_first_category":
> >             //this will print your categories line
> >               echo("<option>".$key."</option>");
> >                 //this loops to the array of the other info
> >                 while($key=="my_first_category")
> >                     {
> >
> > echo("<option>&nbsp;&nbsp;&nbsp;".$myvar_x.[$i]"</option>");
> >                    $i++;
> >                     //this will get you the next element of 
> the array that
> > is within the "my_first_category"
> >                     }//end while
> >     default:
> >        }//end of switch
> >     }//end for each
> >
> > //ACTUALLY i will do this way the switch so i wouldnt have 
> to write all
> the
> > cases of course may be the swithc is not necesary at all 
> but this is just
> an
> > idea
> >
> >  foreach ($category AS $key)
> >     {
> >         switch($key)
> >             {
> >             case "Jorge":
> >             break;
> >             default:
> >             //this will print your categories line
> >               echo("<option>".$key."</option>");
> >                 //this loops to the array of the other info
> >                 while($key=="my_first_category")
> >                     {
> >
> > echo("<option>&nbsp;&nbsp;&nbsp;".$myvar_x.[$i]"</option>");
> >                    $i++;
> >                     //this will get you the next element of 
> the array that
> > is within the "my_first_category"
> >                     }//end while
> >     default:
> >        }//end of switch
> >     }//end for each
> >
> >
> >
> >         Saludos
> >
> > Jorge
> >
> 
> 
> 
> 
> 

  Return to Index