atticus Posted June 27, 2010 Share Posted June 27, 2010 Hi all, I want to put the data from MySQL into a regular array so that I can use array_unique to to remove duplicate data. I need all three variables to be associated with one index point. $months = array(); $i = 0; while($row = mysql_fetch_array($query)) { $monthname = $row['MONTHNAME(`time`)']; $year = $row['YEAR(`time`)']; $month = $row['MONTH(`time`)']; $months[] = ($i => $monthname,$year, $month); $i++; Quote Link to comment https://forums.phpfreaks.com/topic/205966-mysql-row-to-array-syntax-question/ Share on other sites More sharing options...
Alex Posted June 27, 2010 Share Posted June 27, 2010 You can prevent duplicate rows by using a DISTINCT clause in your SQL query. That's more of a MySQL question though, so if you want help with that head over the MySQL help forum. Quote Link to comment https://forums.phpfreaks.com/topic/205966-mysql-row-to-array-syntax-question/#findComment-1077749 Share on other sites More sharing options...
atticus Posted June 27, 2010 Author Share Posted June 27, 2010 Distinct, of course! Dr. Qu would be shaking his head after spending countless hours trying to pump that db stuff in my head back in the day...thanks for pointing me in the right direction. Quote Link to comment https://forums.phpfreaks.com/topic/205966-mysql-row-to-array-syntax-question/#findComment-1077750 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.