Ok, that's working. I realized tho that some campuses will have a "," in
their name (University of California, Riverside) so changed

$c = implode( ', ', $c );

To

$c = implode( '; ', $c );

Thanks,
James

-----Original Message-----
From: Chris Boget [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 11, 2003 1:42 PM
To: James Johnson; [EMAIL PROTECTED]
Subject: Re: [PHP] Array to List


Everything is fine in your script up to here:

> $row_GetCampuses = mysql_fetch_assoc($GetCampuses);

The above is getting just one (1) record from the database.  If you ever
have only one, you are good to go.

> $totalRows_GetCampuses = mysql_num_rows($GetCampuses);

I'm not sure what you are doing with this as I don't see it anywhere in your
included script.

> $c = implode( ', ', $row_GetCampuses );

And all this is doing is comma delimiting the values for each of the 
fields in your 'campuses' table.

This is what you want to do:

<?
//blah
mysql_select_db($database_CCB, $CCB);
$query_GetCampuses = "SELECT * FROM campuses WHERE inst_id IN
($cList) ORDER BY name ASC";
$GetCampuses = mysql_query($query_GetCampuses, $CCB) or die(mysql_error());

$c = array();
while( $rowData = mysql_fetch_assoc( $GetCampuses )) {
  $c[] = $rowData['name'];

}
$c = implode( ', ', $c );

//blah
?>

<table>
<tr><td>Campuses: <?php echo $c; ?></td></tr>

Check out these sites:

PHPBuilder.com
webmonkey.com

Both have really good tutorials/resources dealing with both arrays and
working with data from databases.  You could use both, I would think.

Good luck!

Chris



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

Reply via email to