This is a discussion on "Newbie needs help with Basic Sorting - How do I group items using say an id tag?" within the PHP Forum section. This forum, and the thread "Newbie needs help with Basic Sorting - How do I group items using say an id tag? are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Newbie needs help with Basic Sorting - How do I group items using say an id tag?
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Newbie needs help with Basic Sorting - How do I group items using say an id tag?
Greetings - I am a absolute newbie to PHP/MySQL and would appreciate kickstart help.
I have attempted a tutorial presented at DMX Zone but failed to make it work. You may care to see what I mean by looking at their site. I will add the link details once this posting has been accepted by your forum. Here is my scenario Basic Setup: Database: MySQL id Name 0 Fruit 1 Banana 1 Pineapple 1 Kiwi Fruit 1 Apples 0 Vegetable 6 Tomatoes 6 Peas 6 Carrots Output required: Fruit Apples Banana Kiwi Fruit Pineapple Vegetable Carrots Peas Tomatoes Requirement: Depending on the designated id, all items starting with 0 should display as bold category headings listed in alphbetical order and all associated products matching that category would be listed - also in alphabetical order. Ultimately I will be changing the id column to a specific Products Part No. but the above example is consistant with the DMX Zones example and is simple (hopefully) to illustrate how I may achieve the desired output. A working code sample - or suggested tutorial sites would be greatfully received Thanks in anticipation PS. I'm using Dreamweaver 8 / PHP / MySQL (latest versions) |
|
|
|
#2
|
|||
|
|||
|
Re: Newbie needs help with Basic Sorting - How do I group items using say an id tag?
GROUP BY
in the database command. |
|
#3
|
|||
|
|||
|
Re: Newbie needs help with Basic Sorting - How do I group items using say an id tag?
Thanks - can you give me a sample script for same? Please.
Check out the tutorial I started with at DMXZone at (all one line address): http://www.dmxzone.com/showDetail.asp? d=2&NewsId=4937 I'm a newbie and have followed the tutorial but DW8 seems to generate different code to that displayed. I presume there is an error here somewhere but I don't know enough to work in out myself. A little personal coaching / mentorship would be greately received. Thanks heaps |
|
#4
|
|||
|
|||
|
Re: Newbie needs help with Basic Sorting - How do I group items using say an id tag?
Dont use dreamweaver, it doesnt handle dynamic code well. Thats where your going wrong, hand code it in an editor such as crimson editor.
To download it go to www.downloads.com then put crimson editor in the search box. |
|
#5
|
||||
|
||||
|
Re: Newbie needs help with Basic Sorting - How do I group items using say an id tag?
Really your database is not optimally formed. Here is my immediate reaction for db MYSQL:
|
|
#6
|
|||
|
|||
|
Re: Newbie needs help with Basic Sorting - How do I group items using say an id tag?
Mason, the group by clause is wrong in the code you have posted. You need to include EVERY non aggregate column from the select clause in the group by clause. Failing to do so in any other database except mysql will result in an error and the code won't produce a result. Mysql warns in their manual about GROUP BY HIDDEN FIELDS and that it can produce incorrect results.
|
![]() |
| Tags |
| newbie, needs, help, basic, sorting, group, items, using, say, tag |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need help sorting an array | djeyewater | PHP Forum | 6 | Apr 18th, 2008 15:16 |
| Newbie Question- Basic HTML email method="post" | Bagel | Web Page Design | 4 | Aug 18th, 2006 12:03 |
| Basic Sorts - How do you group items using id tag? Newbie Kickstart | AceTutor | PHP Forum | 7 | Aug 15th, 2006 12:42 |