I wanna know if it's possible to have multiple dimensions in a php array. I have 7 columns in my database and I need the data to a respective variable code:
$months = Array();
$months = ['January'=>array(), 'February'=>array(), 'March'=>array(), 'April'=>array(), 'May'=>array(), 'June'=>array(), 'July'=>array(), 'August'=>array(), 'September'=>array(),
'October'=>array(), 'November'=>array(), 'December'=>array() ];
// Connect to MySQL
if ( !( $database = mysql_connect( "localhost",
"root", "" ) ) )
die( "Could not connect to database </body></html>" );
// open Events database
if ( !mysql_select_db( "Events", $database ) )
die( "Could not open Events database </body></html>" );
foreach($months as $month => $arr) {
$result = mysql_query("SELECT * FROM posted_events WHERE Month_ = '$month' ")
or die ('Error updating database because: '.mysql_error());
}
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$months[$month][] = $row['DayNum'];
}
}
So you can see $months
is a two dimensional array containing a month and the days for that month in my database. But in my database I have other stuff like EVENTNAME, STARTTIME, ENDTIME, DESCRIPTION ETC...and I want to store those in a way like:
May 13th 12pm have the following events => all the events. Help please, thanks.