RE: [PHP] Array to List
| From: | James Johnson | Date: | Mon, 11 Aug 2003 21:01:34 +0000 |
| Subject: | RE: [PHP] Array to List | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-159195@lists.php.net to get a copy of this message | ||
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:chris@wild.net]
Sent: Monday, August 11, 2003 1:42 PM
To: James Johnson; php-general@lists.php.net
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