rockinaway Posted January 21, 2007 Share Posted January 21, 2007 How can I group an array together with a selected title name, that is taken from my database? Link to comment https://forums.phpfreaks.com/topic/35114-grouping-an-array-with-a-name/ Share on other sites More sharing options...
Hypnos Posted January 21, 2007 Share Posted January 21, 2007 Your question is far too vague to directly answer. You have to provide examples for a question like that.But, it depends on your table structure, and how you want the array grouped exactly. For instance, this:while($row = mysql_fetch_assoc($results)) {$arr[$row['title']] = $row['subject'];}Would work fine if your title was a primary key (and if my offhand coding was 100% accurate and without error).The array would come out something like this:$arr["PHP in 24 Hours"] = "PHP";$arr["Learning PHP"] = "PHP";$arr["Learning Perl"] = "Perl";Just remeber that each "row" in an array has to have a unique key. Link to comment https://forums.phpfreaks.com/topic/35114-grouping-an-array-with-a-name/#findComment-165738 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.