timmah1 Posted January 27, 2016 Share Posted January 27, 2016 I'm trying to get info from my database into an event calendar, but I'm lost as to what I need to do here. Can anybody help me out? Thanks in advance $sql = "SELECT * FROM events"; $result = $connection->query($sql); while($row = $result->fetch_assoc()){ $events = array( array( 'id' => $row['id'], 'title' => $row['event'], 'start' => $row['eventDate'] ) ); echo json_encode($events); } ?> This currently shows results like this [{"id":"1018","title":"Free Lunch Friday","start":"2016-01-29 12:30:00"}][{"id":"1020","title":"College Football Championship Game","start":"2016-01-11 00:00:00"}] I want to be like this array( 'id' => $row['id'], 'title' => $row['event'], 'start' => $row['eventDate'] ), array( 'id' => $row['id'], 'title' => $row['event'], 'start' => $row['eventDate'] ) Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted January 27, 2016 Solution Share Posted January 27, 2016 Do you mean while($row = $result->fetch_assoc()){ $events[] = array( 'id' => $row['id'], 'title' => $row['event'], 'start' => $row['eventDate'] ); } Quote Link to comment Share on other sites More sharing options...
timmah1 Posted January 27, 2016 Author Share Posted January 27, 2016 Thank you simple things elude me most of the time Quote Link to comment 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.