centenial Posted June 10, 2006 Share Posted June 10, 2006 Hi,I have a field in a database table named "features". It has a value of:feature1,feature2,feature3,feature4,feature5 (and so on)I want to display the features in a bulleted list, like this:[code]<li>feature1</li><li>feature2</li><li>feature3</li><li>feature4</li><li>feature5</li>(And so on)[/code]Is there a way I can do this with PHP & Arrays? Can anyone show me a code example?Thanks! Link to comment https://forums.phpfreaks.com/topic/11662-separate-a-string-into-a-list-with-php/ Share on other sites More sharing options...
joquius Posted June 10, 2006 Share Posted June 10, 2006 [code]$sql = "SELECT * FROM `features` ORDER BY `id` ASC";$result = mysql_query ($sql) or die (mysql_error());while ($feature = mysql_fetch_array ($result)){ ?><li><?=$feature['feature_name']?></li><?}[/code]my mistake$db_feature is the field lets say[code]<?$features = explode (",", $db_feature);foreach ($features as $feature){?><li><?=$feature?></li><?}?>[/code] Link to comment https://forums.phpfreaks.com/topic/11662-separate-a-string-into-a-list-with-php/#findComment-44044 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.