Jump to content

group results under month


proctk

Recommended Posts

HI

I'm trying to create a system that will get results from a table and then group them by month then store them under the appropriate month so that the user can click on the month then the found information will show.  The problem I'm having is getting the information from the table and then grouping it under the correct month. I can get the months to show and hide.

 

any help is excellent

<?php include('../Connections/db.php'); 
/* Check User Script */
session_start();  // Start Session

$user_id = $_SESSION['user_id'];

$get_Children_Birthdays = ("SELECT * FROM Links L, children C WHERE L.User_id = '$user_id' AND C.child_id = L.child_id");

$children_birthdays = mysql_query($get_Children_Birthdays) or die ("Invalid query". mysql_error());

while ($child_R = mysql_fetch_array($children_birthdays)){

$childdob = $child_R['childdob'];
$childfirstname[] = $child_R['childfirstname'];
$childlastname[] = $child_R['childlastname'];
$child_array = explode("-",$childdob);
$child_birthday[] = ($year."-".$child_array[1]."-".$child_array[2]);
$child_month_num[] = $child_array[1];

}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<script type="text/javascript">

function toggleNext(el) {
var next=el.nextSibling;
while(next.nodeType != 1) next=next.nextSibling;
next.style.display=((next.style.display=="none") ? "block" : "none");
}

function toggleNextByIdAndTag1(el,tname) {
var ccn="clicker";
clickers=document.getElementById(el).getElementsByTagName(tname);
for (i=0; i<clickers.length; i++) {
	clickers[i].className+=" "+ccn;
	clickers[i].onclick=function() {toggleNext(this)}
	toggleNext(clickers[i]);
}
}

window.onload=function(){toggleNextByIdAndTag1('dlist','dt')}
</script>

<style type="text/css">
.clicker {
cursor:pointer;
color:blue;
}

dl {
position:relative;
width:18em;
margin:auto;
border:1px solid gray;
padding:0.5em;
}
</style>
</head>
<body>

<div id="container">
	<div id="top">
	<?php include('../design/topMenu.php'); ?>
	</div>	
		<div id="subHeader">

		  <p> </p>
	    </div>
<div id="leftnav">

 <?php include('../searchMembers.php'); ?>

</div>
	<div id="Centercontent">

    <dl id="dlist">
         	<dt>January</dt><dd>Test Date</dd>
         	<dt>Febuary</dt>
            <dd>Test Date 2</dd>
         	<dt>March</dt><dd>Test Date 3</dd>
         	<dt>April</dt><dd>Test Date 4</dd>
         	<dt>May</dt><dd>Test Date 5</dd>
         	<dt>June</dt><dd>Test Date 6</dd>
         	<dt>July</dt><dd>Test Date 7</dd>
         	<dt>August</dt>
            		<dd>
                   
          <?php foreach($child_month_num as $bmonth){ 
	   	if($bmonth == 4){
		foreach($childfirstname as $value){
		echo $value;
	  }
	  break;
	  }
	  }
	   
	  ?>
                    </dd>
         	<dt>September</dt><dd>Test Date 9</dd>
         	<dt>October</dt><dd>Test Date 10</dd>
         	<dt>November</dt><dd>Test Date 11</dd>
         	<dt>December</dt><dd>Test Date 12</dd>    
         </dl>
         
</div>

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.