galvin Posted November 17, 2010 Share Posted November 17, 2010 I have this code working fine (thanks to Thorpe). FYI, this code is getting info for each day and putting that info into the array and then later on a calendar is generated and the data gathered here is placed onto each specific day. This is working EXCEPT when there are MULTIPLE data sets on the SAME day. In those cases, it's just displaying the first data set. In other words, if $hunches['day'] = 3 and there is just one data set with that date, it will display that info on the calendar fine. But if there are five data sets with $hunches['day'] = 3, then it only displays the first one. I need it to display all data sets, so any clue how I could alter this code to do that? $sql = "SELECT *, DATE_FORMAT(`dob`, '%e') AS day FROM hunches WHERE poolid = '{$_GET['poolid']}' AND (DATE_FORMAT(`dob`,'%m')) = " . $month1 . " ORDER BY day"; $gethunches = mysql_query($sql, $connection); if (!$gethunches) { die("Database query failed: " . mysql_error()); } else { while ($hunches = mysql_fetch_array($gethunches)) { $days1[$hunches['day']] = array(NULL,NULL,'<span class="red">' . $hunches['firstname'] . '</span>'); } } Here is a further explanation... Say $hunches['day'] = 5 and there are four data sets for that day (with respective firstnames of Bob, Joe, Jim and Tony). I would essentially need this to happen in the code... $days1[$hunches['day']/*which would be 5 in this example*/] = array(NULL,NULL,'<span class="red">' . $hunches['firstname'] . '</span><br> <span class="red">' . $hunches['firstname'] . '</span><br> <span class="red">' . $hunches['firstname'] . '</span><br> <span class="red">' . $hunches['firstname'] . '</span>'); And that would then output... Bob Joe Jim Tony ...in the 5th day box on the calendar. Right now, I'm just getting... Bob I fear this is very complicated to do but holding out hope that there is some relatively easy way to make this work. Quote Link to comment Share on other sites More sharing options...
Jocka Posted November 17, 2010 Share Posted November 17, 2010 ::EDIT:: forget to end the if statement hmm... maybe $info = ''; while ($hunches = mysql_fetch_array($gethunches)) { if($info == ''){ $info .= "<span class=\"red\">" . $hunches['firstname'] . "</span>"; } else { $info .= "<br><span class=\"red\">" . $hunches['firstname'] . "</span>"; // ADDS THE BREAK } } // OUTSIDE OF WHILE STATEMENT $days1[$hunches['day']] = array(NULL,NULL, $info); Quote Link to comment Share on other sites More sharing options...
galvin Posted November 17, 2010 Author Share Posted November 17, 2010 Thanks Jocka, you led me in the right direction and I have it doing what I need. Thanks again! 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.