* Steve Marquez <[EMAIL PROTECTED]>:
> I created a photo upload utility with individual galleries that images can
> be uploaded into. In the MySQL database, there are multiple names of
> galleries, some are the same. I want to have a select menu to show just the
> unique names of the galleries.
>
> I have used:
>
> Select DISTINCT gallery_names from images_upload;
>
> I have about 15 records, ten are "GALLERY1" and 5 are "GALLERY2." When I use
> the DISTINCT, two are output. It works perfectly in the MySQL terminal.
>
> However, when I use the same in PHP as a web page, it only outputs one, the
> one with only 5 records.
>
> Here is the code:
>
> <?php
>
> // log into our local server using the MySQL root user.
> $dbh = mysql_connect( "hostname", "username", "password" );
>
> // select the database.
> mysql_select_db( "db" ) or die ( mysql_error() . "\n" );
>
> //and read it back for printing purposes.
> $get_table_data = "SELECT DISTINCT gallery_name FROM images_upload ORDER
> BY gallery_name DESC";
>
> $response = mysql_query( $get_table_data, $dbh );
>
> //now print it out for the user.
> if ( $one_line_of_data = mysql_fetch_array( $response ) ) {
It's only printing out one record because you're only fetching from the
results set once. Change that to :
while ($one_line_of_data = mysql_fetch_array($response)) {
and you should be set.
--
Matthew Weier O'Phinney | mailto:[EMAIL PROTECTED]
Webmaster and IT Specialist | http://www.garden.org
National Gardening Association | http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php