PDA

View Full Version : Group records by month with single header


Daryl
06-22-2008, 01:48 PM
I am trying to achieve the following;

Month 1
Date 1 Item 1 Location 1
Date 2 Item 2 Location 2
Date 3 Item 3 Location 3

Month 2
Date 4 Item 4 Location 4
Date 5 Item 5 Location 5
Date 6 Item 6 Location 6


I am using php and am collecting my data from a mysql database
I have been using Dreamweaver to build my website, however using the repeat region tool, the nearest that I can get is to have the month above each record.
Thanks in advance for any help that you might be able to give!

davidj
06-22-2008, 04:55 PM
learn to code then i may be able to help

Daryl
06-22-2008, 05:22 PM
I am trying to learn thats why I am here!

My database consists of the following fields

id
start_date
finish_date
course_type
location_address
location_map
price

I have the page setup so that I can see the data, I have also managed to extract the month from the sql date from the column start_date
I have managed to get the month to show as a header above the course information for that month and subsequant months, however if I have more than one course in a month it shows the header above each entry.

The query looks something like this


<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_Strata, $Strata);
$query_Courses = "SELECT * FROM courses WHERE courses.start_date >= CURRENT_DATE() ORDER BY start_date DESC";
$Courses = mysql_query($query_Courses, $Strata) or die(mysql_error());
$row_Courses = mysql_fetch_assoc($Courses);
$totalRows_Courses = mysql_num_rows($Courses);
?>


And the code looks something like this


<?php do { ?>
<table width="100%" border="1">
<tr>
<td colspan="6"><?php echo date('F',strtotime($row_Courses['start_date'])); ?></td>
</tr>
<tr>
<td><?php echo $row_Courses['start_date']; ?></td>
<td><?php echo $row_Courses['finish_date']; ?></td>
<td><?php echo $row_Courses['course_type']; ?></td>
<td><?php echo $row_Courses['location_address']; ?></td>
<td><?php echo $row_Courses['location_map']; ?></td>
<td><?php echo $row_Courses['price']; ?></td>
</tr>
</table>
<?php } while ($row_Courses = mysql_fetch_assoc($Courses)); ?>

davidj
06-22-2008, 05:26 PM
no that is dreamweaver code

once you commit to learning how to code then i can help until then you will have to wait until someone comes along to help you with your DW code

i made a promise that i never help anyone who has used DW to write their code

if you want to learn then i am here but it requires commitment

domedia
06-23-2008, 03:17 PM
You're good Daryl, you just happened to post this in the wrong forum. This is a handcoders forum, moving to the Dreamweaver forum.

edbr
06-25-2008, 03:45 AM
you might not be able to do this using DW's wizard without re coding.

if i understand what you want to achieve, you need a where clause to select by month. you could try by using 2 recordsets maybe. ie recordset 1 where date = june, recordset 2 where date = july