Jump to content

Multiple data sets on same array index??


galvin

Recommended Posts

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.

Link to comment
Share on other sites

::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);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.