To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > Tools > Dreamweaver

Dreamweaver In need of help with Dreamweaver?

Reply
 
Thread Tools Rate Thread Display Modes
Old 03-11-2003, 06:50 AM   #1
Jim_Madrid
Member
 
Join Date: Feb 2003
Posts: 41
displaying search results in a non repeating way

PHP & MYSQL

I have a taxonomic database of animal species (phylum, class, order, family, species, etc) and would like to know if there is a way to display search results without repeating each category for each species. In other words, I want to avoid example 1 and achieve example 2. That is, if the name of the species changes but the prior categories stay the same I donīt want to repeat every category.

Example 1 NO!

Class Order Family Species 1
Class Order Family Species 2
Class Order Family Species 3
Class Order 2 Family 2 Species 4
Class Order 2 Family 2 Species 5
Class Order 2 Family 2 Species 6
Class Order 2 Family 3 Species 7
Class Order 2 Family 3 Species 8

Example 2 YES!

Class Order Family Species 1
Species 2
Species 3
Order 2 Family 2 Species 4
Species 5
Species 6
Family 3 Species 7
Species 8


Any ideas would be greatly appreciated.

James
Jim_Madrid is offline   Reply With Quote
Old 03-13-2003, 06:52 PM   #2
Pig
Man I'm pretty
 
Pig's Avatar
 
Join Date: Oct 2002
Location: close, so very close...
Posts: 1,015
PHP Code:
$result = mysql_query("SELECT * FROM table_name")
while(
$row = mysql_fetch_array($result) )
     {
     
$row0 = $row[0];
     
$row1 = $row[1]
     
$row2 = $row[2]
     
$row3 = $row[3]

     if(
$row0 == $row0set )
          {
          unset(
$row0);
          }
     if(
$row1 == $row1set )
          {
          unset(
$row1);
          }
     if(
$row2 == $row2set )
          {
          unset(
$row2);
          }

    echo(
"
          $row0, $row1, $row2, $row3
            "
);
     
$row0set = $row0;
     
$row1set = $row1;
     
$row2set = $row2;    
     }
Someone try that and see if it works. I'm at work and cant do it from here.

The idea is that if a new items comes along, it'll be printed, other wise it gets blanked. That is, a new value for $rowX will keep it from being unset, and every identical one after that will match, and there fore get unset.

Lemme know if that worked.
Pig is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 12:44 PM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.