Created Comma Seperated List from MySQL DB
6
Pull items from a mysql db table and display in the following format-
item1, item2, item3
In the example code, the query will return all items that have the color "red" specified in the db.
item1, item2, item3
In the example code, the query will return all items that have the color "red" specified in the db.
<?
$query = mysql_query("SELECT item FROM table WHERE color = 'red'");
$system_array = array() ;
$i = 0 ;
while ( $row = mysql_fetch_assoc( $query ) )
{
$system_array[ $i ] = $row[ 'item' ] ;
$i++ ;
}
$item_list = implode( ', ', $system_array ) ;
echo $item_list;
?>
Comments
Thu. Mar. 1st, 2007 4:26 PM
Nico
Nico




