First, please respond on list.

Second, I know what max does.  However, you'll be disappointed in its use
here.  This while() will execute ONLY ONCE so a while() construct is of no
use here.

The syntax I sent you is correct.  It will select all categories and IDs by
category, then ID in a descending order, per your statement.  What you would
do is keep track of which category you are listing.  As you read each
record, you would compare the newly-read category to the category you are
currently listing.  If the new category is different, you would then create
a new category title.

Another method, would be two selects.  The first select would control an
outer loop; this would be the category loop.  The inner loop would first
select all reviews for that category and then print out each.

-----Original Message-----
From: Alex Behrens [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 03, 2002 4:37 PM
To: Rick Emery
Subject: Re: help sorting by a column name


Oh thats teh statement that gets the number for this statement:
while ($info = mysql_fetch_row($max)) {
printf ("<b><font color='#ffffff'>Hardware Reviews - %s Articles
Total</b></font><br>", $info["0"]);
}
and prints the total number of articles.

however, I dont think the syntax you sent me is write.

this is what I want it to do, but dont know how to program it:

Print $category Review
then print reviews for that category

then Print $category Review (Another category of reviews)
then print reviews for this category

etc, etc.

get what i mean?

Thanks!
--------------------------------------------
-Alex "Big Al" Behrens
E-mail: [EMAIL PROTECTED]
Urgent E-mail: [EMAIL PROTECTED] (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:
[EMAIL PROTECTED]
----- Original Message -----
From: "Rick Emery" <[EMAIL PROTECTED]>
To: "'Alex Behrens'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, April 03, 2002 4:33 PM
Subject: RE: help sorting by a column name


> $r = mysql_query("SELECT * FROM hwureviews ORDER BY category,num DESC");
>
> what are you trying to do with this statement?:
> while ($info = mysql_fetch_row($max)) {
>
>
>
> -----Original Message-----
> From: Alex Behrens [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, April 03, 2002 4:08 PM
> To: [EMAIL PROTECTED]
> Subject: help sorting by a column name
>
>
> Hey Guys,
>
> I need to reorganize the list of reviews on my site so they are displayed
by
> category. However, I want it to display all the reviews from all
categories
> at once. How do I do this? Here is my syntax now for display all reviews
at
> once, but not sorted by category:
>
> <?php
> $db = mysql_connect( "db32.pair.com",  "**********",  "********");
> mysql_select_db( "net3dual_reviews",$db);
> $r = mysql_query("SELECT * FROM hwureviews ORDER BY num DESC");
> $max = mysql_query("select max(num) from hwureviews",$db);
> while ($info = mysql_fetch_row($max)) {
> printf ("<b><font color='#ffffff'>Hardware Reviews - %s Articles
> Total</b></font><br>", $info["0"]);
> }
> while($a=mysql_fetch_array($r)) {
> printf ("- <a href=\"%s\">%s</a> (Written by: <a
> href=\"mailto:%s\";>%s</a>) - [<a href='%s' onMouseOver='if (window.event
||
> document.layers) show(\"%s\",event)'
>
onMouseOut='hide(\"%s\")'>Description</a>]<br>",$a["url"],$a["name"],$a["ema
> il"],$a["author"],$a["url"],$a["name"],$a["name"]);
> }
> ?>
>
> I want it so it displays them like this:
>
> Processors -
> Reviews listed here
>
> Motherboards
> Reviews listed here
>
> the categories are stored under the column name "category", for reference.
>
> Thanks!
> --------------------------------------------
> -Alex "Big Al" Behrens
> E-mail: [EMAIL PROTECTED]
> Urgent E-mail: [EMAIL PROTECTED] (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:
> [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to