Re: creating subheads in an array

From: Date: Mon, 30 Oct 2000 20:19:57 +0000
Subject: Re: creating subheads in an array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-22742@lists.php.net to get a copy of this message
Sure do this: <? $shown = array(); $sql = "SELECT * FROM products ORDER BY categor"; $r = mysql_query($sql); while($row = mysql_fetch_array($r)){ // turn $row['id'] , etc into $id // aka variable variables while(list($key,$val) = each($row)){ $$key = stripslashes($val); } if(!in_array($category,$shown)){ echo '<TR><TD COLSPAN="x" ALIGN="center">'.$category.'</TD></TR>'; $shown[] = $category; } // echo rows ... } ?> --Joe On Mon, Oct 30, 2000 at 11:13:03AM -0800, Tom Beidler wrote: > I've setup a site that dumps a product list into a table. There are > approximately 500 products and the client prefers that the initial page > shows all 500 products. Each product has a category, description, > application, part number, price and comments field. I'm trying to keep > horizontal space to a minimum, so currently I don't list category. What I > would like to do is create a table and have a separate row inserted for each > category to break up the items. > > So, when I display all of the products sorted by category, each new category > would have a row inserted before it with its category name. When a new > category would start, a new row would be inserted before with the category > name, continuing down for however may categories are present. > > Can this be done? I'm currently using alternating colored rows and I thought > it might be similar. Maybe too complex though. > > Thanks for any assistance, > Tom > > >>.>>.>>>.>>>>>.>>>>>>>>> > Tom Beidler > Orbit Tech Services > 805.455.7119 (cell) > 805.682.8972 (phone) > 805.682.5833 (fax) > tbeidler@mindspring.com > >>.>>.>>>.>>>>>.>>>>>>>>> > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net ================================================================================ = Joe Stump joestump98@yahoo.com http://www.miester.org = ================================================================================ "Real programmers don't comment their code. It was hard to write, it should be hard to understand."

« previous php.general (#22742) next »