Re: phpmysql(which array function?)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



$query = "select column1, column2 from table order by column1";
$result = mysql_query ($query)
        or die ("Query Failed, " . mysql_error ());
$column1 = 'Zilch';
$counter = 0;
while ($line = mysql_fetch_array ($result)) {
        if ($column1 != $line[0]) {
                $column = $line[0];
                $counter += 1;
                print ("<br><br>$counter. column1: $line[0]<br>");
                print ("column2: $line[1]");
        }
        else print (",$line[1]");
}

this should do the trick ...
andrei




Joffrey Leevy <joffrey_leevy1@xxxxxxxxx> 
2003/11/08 01:50 PM

To
php-db@xxxxxxxxxxxxx
cc

Subject
Re:  phpmysql(which array function?)







Please excuse the previous post.  Table unformatted.

Hi all:

Trying to solve a phpmysql array problem.

Let's say I have a table in mysql format

Column1   Columnn2

dog       brown

cat       white

cat       black

cat       mixed

pig       black

pig       brown



What kind of (query, array function, loop, etc...)
should I use to produce an html output like this:

1. column1:dog
column2:brown

2.  column1:cat
column2: white, black,mixed

3.  column1: pig
column2: black, brown



I figure I have to use the implode function.

Thanks in advance
J


__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux