PHP Applications
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Applications

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old March 18th, 2007, 02:26 AM
dmschenk dmschenk is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 31 dmschenk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 19 m 43 sec
Reputation Power: 2
Help with Grouping

I am trying to replicate an Event calendar from the link below with a database driven one however I am having trouble with grouping. I can't seem to get multiple events that occur in the same month to show up under a single month header. if you follow the link below you will see what I am trying to accomplish.
http://internationalsoaringeaglesministries.org/calendar.php

Here is what the database version consists of:

**Calendar Table
CalendarID (int) Primary Key
EventDays (varchar) lists the days of the event (ex: 2 - 5)
EventDesc (varchar) detail of the event
EventLoc (varchar) location of the event
Date (TIMESTAMP) date entered into DB
Online (TINYINT) is displayed online or not


MySQL Statement for Recordset:

SELECT *
FROM calendar
GROUP BY (calendar.Date)

In the web page I currently have a single repeat region around the whole calendar area.

Also I am using PHP5 and MySQL5

I would be very appreciative if someone could straighten me out here

Thanks
Dave

Reply With Quote
  #2  
Old March 18th, 2007, 05:06 AM
raiyen raiyen is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 18 raiyen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Help with Grouping

$result = mysql_query( "select month( date ) as thismonth,date from calendar" );

if( count( $result ) )
{
$month = array( );
while( $value = mysql_fetch_assoc( $result ) )
{
$month[ $value[ 'thismonth' ] ][] = $value['date'];
}
foreach( $month as $key => $m )
{
echo "month: $key";
foreach( $m as $date )
{
echo $date;
}
}
}
-----------------------------------------------
I haven't tried this..
Get back to me if there are errors.

Reply With Quote
  #3  
Old March 19th, 2007, 02:53 PM
dmschenk dmschenk is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 31 dmschenk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 19 m 43 sec
Reputation Power: 2
RE: Help with Grouping

I'm afraid that I'm quite the newbie when it comes to coding so I don't really know where or how to impliment your code.

I can post what I do have already and if you would please splain it to me what I need to do.

************************************************** ********
This is the sql for the database with 4 entries for testing:
************************************************** ********
php Code:
Original - php Code
  1.  
  2. -- phpMyAdmin SQL Dump
  3. -- version 2.10.0.2
  4. -- [www.phpmyadmin.net]
  5. --
  6. -- Host: localhost
  7. -- Generation Time: Mar 18, 2007 at 10:28 AM
  8. -- Server version: 5.0.27
  9. -- PHP Version: 5.2.1
  10.  
  11. SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
  12.  
  13. --
  14. -- Database: `dmschen_isem`
  15. --
  16.  
  17. -- --------------------------------------------------------
  18.  
  19. --
  20. -- Table structure for table `calendar`
  21. --
  22.  
  23. CREATE TABLE `calendar` (
  24. `CalendarID` int(11) NOT NULL auto_increment,
  25. `Date` date NOT NULL,
  26. `EventDate` varchar(15) NOT NULL default '',
  27. `EventDesc` text NOT NULL,
  28. `EventLocation` varchar(50) NOT NULL default '',
  29. `OnLine` tinyint(4) NOT NULL default '0',
  30. PRIMARY KEY (`CalendarID`)
  31. ) ENGINE=MyISAM  ROW_FORMAT=DYNAMIC COMMENT='ISEM Calendar of Events' AUTO_INCREMENT=5 ;
  32.  
  33. --
  34. -- Dumping data for table `calendar`
  35. --
  36.  
  37. INSERT INTO `calendar` (`CalendarID`, `Date`, `EventDate`, `EventDesc`, `EventLocation`, `OnLine`) VALUES
  38. (1, '2007-06-13', '1', 'EACM Conference', 'Roseville, MI', 0),
  39. (2, '2007-06-13', '1', 'Women''s Retreat', 'Ypsilanti, MI', 1),
  40. (3, '2007-06-29', '26 - 28', 'Gospel Revival', 'Selfridge Chapel, MI', 0),
  41. (4, '2007-08-15', '13 - 18', 'Couples Retreat', 'Selfridge', 1)





************************************************** ********
This is the code for the page with everything striped out:
************************************************** ********
php Code:
Original - php Code
  1.  
  2. <?php require_once('../Connections/ISEMCal.php'); ?>
  3. <?php
  4. if (!function_exists("GetSQLValueString")) {
  5. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  6. {
  7. $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.  
  9. $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  10.  
  11. switch ($theType) {
  12. case "text":
  13. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  14. break;
  15. case "long":
  16. case "int":
  17. $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  18. break;
  19. case "double":
  20. $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
  21. break;
  22. case "date":
  23. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  24. break;
  25. case "defined":
  26. $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  27. break;
  28. }
  29. return $theValue;
  30. }
  31. }
  32.  
  33. mysql_select_db($database_ISEMCal, $ISEMCal);
  34. $query_isemCal = "SELECT calendar.EventDate, calendar.EventDesc, calendar.EventLocation, calendar.`Date` FROM calendar GROUP BY (calendar.Date) ";
  35. $isemCal = mysql_query($query_isemCal, $ISEMCal) or die(mysql_error());
  36. $row_isemCal = mysql_fetch_assoc($isemCal);
  37. $totalRows_isemCal = mysql_num_rows($isemCal);
  38.  
  39. function makeStamp($theString) {
  40. if (ereg("([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}): ([0-9]{2}): ([0-9]{2})", $theString, $strReg)) {
  41. $theStamp = mktime($strReg[4],$strReg[5],$strReg[6],$strReg[2],$strReg[3],$strReg[1]);
  42. } else if (ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})", $theString, $strReg)) {
  43. $theStamp = mktime(0,0,0,$strReg[2],$strReg[3],$strReg[1]);
  44. } else if (ereg("([0-9]{2}): ([0-9]{2}): ([0-9]{2})", $theString, $strReg)) {
  45. $theStamp = mktime($strReg[1],$strReg[2],$strReg[3],0,0,0);
  46. }
  47. return $theStamp;
  48. }
  49.  
  50. function makeDateTime($theString, $theFormat) {
  51. $theDate=date($theFormat, makeStamp($theString));
  52. return $theDate;
  53. }
  54. ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  55. "http://www.w3.org/TR/html4/loose.dtd">
  56. <html>
  57. <head>
  58. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  59. <title></title>
  60. </head>
  61.  
  62. <body>
  63. <?php do { ?>
  64. <table width="400" border="2" align="center" cellpadding="10" cellspacing="0">
  65. <tr bgcolor="#E4C6E2">
  66. <td colspan="2" class="monthYear"><div align="center"><?php echo makeDateTime($row_isemCal['Date'], 'F - Y'); ?></div></td>
  67. </tr>
  68. <tr valign="top">
  69. <td width="30%"><p><?php echo $row_isemCal['EventDate']; ?></p></td>
  70. <td width="70%"><?php echo $row_isemCal['EventDesc']; ?><br>
  71. <?php echo $row_isemCal['EventLocation']; ?></td>
  72. </tr>
  73. </table>
  74. <br>
  75. <?php } while ($row_isemCal = mysql_fetch_assoc($isemCal)); ?>
  76. </body>
  77. </html>
  78. <?php
  79. mysql_free_result($isemCal);
  80. ?> 


Thanks
Dave

Reply With Quote
  #4  
Old March 23rd, 2007, 02:26 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Help with Grouping

I would really like to know how to add this code in also!

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Applications > Help with Grouping


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |