Re: grouping by category
| From: | olinux | Date: | Thu, 04 Apr 2002 04:48:27 +0000 |
| Subject: | Re: grouping by category | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-18184@lists.php.net to get a copy of this message | ||
Here's a start - take a look at the results in
phpmyadmin to get an idea of how to loop the result
SELECT url, author, name, category FROM hwureviews
GROUP BY category
olinux
--- Alex Behrens <bigal@3d-unlimited.com> wrote:
> Hey Guys,
>
> I'm trying to get my script to group all my reviews
> by category now but now
> it just displays them all in a row a bunch of times
> and doesn't group them
> how I want it to group them. I want it too look like
> this:
>
> Processor Reviews
> - Review
> - Review
>
> Motherboard Reviews
> - Review
> -Review
>
> Heres my syntax, and the page is online here
> (http://www.hardware-unlimited.com/hardware2.php) so
> you can see how it is
> executed now:
>
> <?php
> $db = mysql_connect( "db32.pair.com", "net3dual_2",
> "*******");
> mysql_select_db( "net3dual_reviews",$db);
>
> file://select cateogries
> $r = mysql_query("SELECT category FROM hwureviews
> ORDER BY num DESC");
> while($a=mysql_fetch_array($r)) {
> $category = $a["category"];
>
> file://select reviews for the current category
> $select_reviews = "select url, author, name from
> hwureviews where
> category='".$a["category"]."'";
> $reviews = mysql_query($select_reviews);
>
> while($rev=mysql_fetch_array($reviews)) {
> $name = $rev["name"];
> $author = $rev["author"];
> $url = $rev["url"];
> $email = $rev["email"];
> file://print out review info
> echo "$category Reviews:<br>";
> echo "- <a href=\"$url\">$name</a> (Written by: <a
> href=\"mailto:$email\">$author</a>) - [<a
> href='$url' onMouseOver='if
> (window.event || document.layers)
> show(\"$name\",event)'
>
onMouseOut='hide(\"$name\")'>Description</a>]<br><br>";
>
> } // end review while
> } // end category while
> ?>
>
> What do I need to do?
>
> Thanks!
> --------------------------------------------
> -Alex "Big Al" Behrens
> E-mail: bigal@3d-unlimited.com
> Urgent E-mail: bigal-cell@3d-unlimited.com (Please
> be brief!)
> Phone: 651-482-8779
> Cell: 651-329-4187
> Fax: 651-482-1391
> ICQ: 3969599
> Owner of the 3D-Unlimited Network:
> http://www.3d-unlimited.com
> Send News:
> news@3d-unlimited.com
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/