Jump to content

runnerjp

Members
  • Posts

    2,214
  • Joined

  • Last visited

Posts posted by runnerjp

  1. ok i dont get it. in my db i have an event called test stored as 03-06-2009  but if  you look at this link http://www.runningprofiles.com/members/diary/cal_show.php?m=6&y=2009 its displayed on every month on the 3rd date :S

     

    <?php 
    $ev_dat = array();
    for ($i=0;$i<32;$i++) {
        $ev_dat[$i]=0;
    }
    
    $now = date("d-m-Y", time());
    list($td, $tm, $ty) = explode('-',$now); // ty=thisyear, etc. used for highlighting 'today'
    
    include("cal_parms.php"); // assorted configuration variables
    include($dat_names); // retrieved from cal_parms.php as a 'language' file
    
    if (!isset($_GET['m'])) { 
        $m = date("m",mktime()); 
    } else {
        $m = $_GET['m'];
    }
    if (!isset($_GET['y'])) {
        $y = date("Y",mktime());
    } else {
        $y = $_GET['y'];
    }
    
    /*== get what weekday the first is on ==*/ 
    $tmpd = getdate(mktime(0,0,0,$m,1,$y)); 
    $month = $tmpd["month"]; 
    $firstwday= $tmpd["wday"]; 
    if ($firstDayIsMonday == 1) {
        if ($firstwday == 0) {
            $firstwday = 6;
        } else {
            $firstwday--;
        }
    }
    $lastday = mk_getLastDayofMonth($m,$y); 
    
    /*== get the last day of the month ==*/ 
    function mk_getLastDayofMonth($mon,$year) 
    {
        for ($tday=28; $tday <= 31; $tday++) 
        {
            $tdate = getdate(mktime(0,0,0,$mon,$tday,$year)); 
            if ($tdate["mon"] != $mon) 
            { 
                break;
            }
        }
        $tday--; 
        return $tday; 
    }
      
    // compute range of dates for this month to match dates in database in the format yyyy-mm-dd
    if (strlen($m)<2) {
        $q="0";
        $q.=$m;
    }
    else {
        $q = $m;
    }    
    $dats_beg = "01-". $q."-". $y ;
    $dats_en =  $lastday . "-". $q. "-".$y ;
      
    // open db conn and select all records where date is between $dats_beg and $dats_en
    include("cal_db_conn.php");
    mysql_connect($db_host, $db_login, $db_pass) or die ("Can't connect!"); 
    mysql_select_db($db_name) or die ("Can't open database!"); 
    $query = "SELECT * FROM $db_table WHERE (ev_dat>='$dats_beg') AND (ev_dat<='$dats_en') "; 
      
    $result = mysql_db_query($db_name, $query); 
    // any matches?
    if ($result)
    {
        // handle the matches and pass relevant info to arrays
        while ($myrow = mysql_fetch_array($result)) 
        { 
            $found = $myrow['ev_dat'];
            $pieces = explode("-", $found);
            $dd = intval($pieces[0]);
            $ev_dat[$dd] = $myrow['id'];
        }
    }
    ?> 
    <table cellpadding="1" cellspacing="1" border="0" bgcolor="#<? echo $bg_edge; ?>"> 
    <tr><td colspan="7" bgcolor="#<? echo $bg_top; ?>"> 
    <table cellpadding="1" cellspacing="1" border="0" width="100%"> 
    <tr bgcolor="#<? echo $bg_top; ?>"><th width="20" style="<?php echo $hcell; ?>"><a href="<? echo $_SERVER['PHP_SELF']; ?>?m=<?=(($m-1)<1) ? 12 : $m-1 ?>&y=<?=(($m-1)<1) ? $y-1 : $y ?>"><img src='http://www.runningprofiles.com/calendar/images/prev.gif' height='18' width='18' alt='' border='0' /></a></th> 
    <th style="<?php echo $hcell; ?>">
    <?php
    echo  "<a href='../members/diary/show-month.php?mon=". $m. "&yr=". $y. "'rel=\"facebox\">";
    echo "<span style='text-decoration:none'>". $mo[intval($m)]. " ". $y. "</span></a>";
    ?>
    </th> 
    <th width="20" style="<? echo $hcell; ?>"><a href="<? echo $_SERVER['PHP_SELF']; ?>?m=<?=(($m+1)>12) ? 1 : $m+1 ?>&y=<?=(($m+1)>12) ? $y+1 : $y ?>"><img src='http://www.runningprofiles.com/calendar/images/next.gif' height='18' width='18' border='0' alt='' /></a></th> 
    </tr>
    </table> 
    </td></tr> 
    <tr bgcolor="#<? echo $bg_top; ?>">
    <th width="20" style="<?php echo $hcell; ?>"><? echo $da[1]; ?></th>
    <th width="20" style="<?php echo $hcell; ?>"><? echo $da[2]; ?></th> 
    <th width="20" style="<?php echo $hcell; ?>"><? echo $da[3]; ?></th>
    <th width="20" style="<?php echo $hcell; ?>"><? echo $da[4]; ?></th>
    <th width="20" style="<?php echo $hcell; ?>"><? echo $da[5]; ?></th>
    <th width="20" style="<?php echo $hcell; ?>"><? echo $da[6]; ?></th> 
    <th width="20" style="<?php echo $hcell; ?>"><? echo $da[7]; ?></th>
    </tr> 
        
    <?  
    $d = 1; 
    $wday = $firstwday; 
    $firstweek = true; 
    /*== loop through all the days of the month ==*/ 
    while ( $d <= $lastday) 
    { 
        /*== set up blank days for first week ==*/ 
        if ($firstweek) 
        {
            if ($wday!=0) {     
                echo "<tr bgcolor='#". $bg_tabl. "'>\n";
                for ($i=1; $i<=$firstwday; $i++) { 
                     echo "<td style='". $tcell. "' bgcolor='#". $bg_fill. "'> </td>\n"; 
                }
            }
            /*== Sunday start week with <tr> ==*/ 
            else { 
                echo "<tr bgcolor='#". $bg_tabl. "'>\n";
            } 
            $firstweek = false;
        }
        /*== check for event ==*/   
        echo "<td style='". $tcell. "' ";
        // is this day 'today' AND there's no event today
        if (($ty==$y) && ($tm==$m) && ($td == $d) && (!$ev_dat[$d])) { 
            echo "bgcolor='#". $bg_now. "'>". $d;
        }
        elseif ($ev_dat[$d]) {
            // get what's happening that day and use as 'mouseOver' for the link
            $query = "SELECT * FROM $db_table WHERE id=$ev_dat[$d] ";
            $result = mysql_query($query); 
            $ev = mysql_fetch_array($result);
            $titl = $ev['ev_title'];
            echo "bgcolor='#". $bg_act. "'>";
            $url = "../members/diary/show.php?event=". $ev_dat[$d]. "&sho=". $win_sho;
          
                 echo "<a href=' $url' rel=\"facebox\" title=\"". $titl. "\">". $d. "</a>";
           
        }
        else {
            echo "bgcolor='#". $bg_days. "'>". $d; 
        }
        echo "</td>\n"; 
    
        /*== Saturday end week with </tr> ==*/ 
        if ($wday==6) {
            echo "</tr>\n"; 
        }
        $wday++; 
        $wday = $wday % 7; 
        if (($wday==0) AND ($d!=$lastday)){ echo "<tr bgcolor='#". $bg_tabl. "'>\n"; }
            $d++; 
        }
        // and close off the table
        if (($wday!=7) AND ($wday!=0)) {
            for ($i=$wday; $i<=6; $i++) {
                echo "<td style='". $tcell. "' bgcolor='#". $bg_fill. "'> </td>\n";
            }
            echo "</tr>";
        } 
    echo "\n</table>"; 
    include("win_open.php");
    ?> 

  2. OK THAT DIDNT DO IT!

     

    so if i have chnaged the data to dd-mm-yyyy

     

    what would i need to chnage this too so it now works with dd-mm-yyy to find events held on that day??

     

    <?php // compute range of dates for this month to match dates in database in the format yyyy-mm-dd
    if (strlen($m)<2) {
        $q="0";
        $q.=$m;
    }
    else {
        $q = $m;
    }    
    $dats_beg = $y. "-". $q. "-01";
    $dats_en = $y. "-". $q. "-". $lastday;
      
    // open db conn and select all records where date is between $dats_beg and $dats_en
    include("cal_db_conn.php");
    mysql_connect($db_host, $db_login, $db_pass) or die ("Can't connect!"); 
    mysql_select_db($db_name) or die ("Can't open database!"); 
    $query = "SELECT * FROM $db_table WHERE (ev_dat>='$dats_beg') AND (ev_dat<='$dats_en') "; 
      
    $result = mysql_db_query($db_name, $query); 
    // any matches?
    if ($result)
    {
        // handle the matches and pass relevant info to arrays
        while ($myrow = mysql_fetch_array($result)) 
        { 
            $found = $myrow['ev_dat'];
            $pieces = explode("-", $found);
            $dd = intval($pieces[2]);
            $ev_dat[$dd] = $myrow['id'];
        }
    }
    ?> 
    <table cellpadding="1" cellspacing="1" border="0" bgcolor="#<? echo $bg_edge; ?>"> 
    <tr><td colspan="7" bgcolor="#<? echo $bg_top; ?>"> 
    <table cellpadding="1" cellspacing="1" border="0" width="100%"> 
    <tr bgcolor="#<? echo $bg_top; ?>"><th width="20" style="<?php echo $hcell; ?>"><a href="<? echo $_SERVER['PHP_SELF']; ?>?m=<?=(($m-1)<1) ? 12 : $m-1 ?>&y=<?=(($m-1)<1) ? $y-1 : $y ?>"><img src='http://www.runningprofiles.com/calendar/images/prev.gif' height='18' width='18' alt='' border='0' /></a></th> 
    <th style="<?php echo $hcell; ?>">
    <?php
    echo  "<a href='../members/diary/show-month.php?mon=". $m. "&yr=". $y. "'rel=\"facebox\">";
    echo "<span style='text-decoration:none'>". $mo[intval($m)]. " ". $y. "</span></a>";
    ?>
    </th> 
    <th width="20" style="<? echo $hcell; ?>"><a href="<? echo $_SERVER['PHP_SELF']; ?>?m=<?=(($m+1)>12) ? 1 : $m+1 ?>&y=<?=(($m+1)>12) ? $y+1 : $y ?>"><img src='http://www.runningprofiles.com/calendar/images/next.gif' height='18' width='18' border='0' alt='' /></a></th> 
    </tr>
    </table> 
    </td></tr> 
    <tr bgcolor="#<? echo $bg_top; ?>">
    <th width="20" style="<?php echo $hcell; ?>"><? echo $da[1]; ?></th>
    <th width="20" style="<?php echo $hcell; ?>"><? echo $da[2]; ?></th> 
    <th width="20" style="<?php echo $hcell; ?>"><? echo $da[3]; ?></th>
    <th width="20" style="<?php echo $hcell; ?>"><? echo $da[4]; ?></th>
    <th width="20" style="<?php echo $hcell; ?>"><? echo $da[5]; ?></th>
    <th width="20" style="<?php echo $hcell; ?>"><? echo $da[6]; ?></th> 
    <th width="20" style="<?php echo $hcell; ?>"><? echo $da[7]; ?></th>
    </tr> 
        
    <?  
    $d = 1; 
    $wday = $firstwday; 
    $firstweek = true; 
    /*== loop through all the days of the month ==*/ 
    while ( $d <= $lastday) 
    { 
        /*== set up blank days for first week ==*/ 
        if ($firstweek) 
        {
            if ($wday!=0) {     
                echo "<tr bgcolor='#". $bg_tabl. "'>\n";
                for ($i=1; $i<=$firstwday; $i++) { 
                     echo "<td style='". $tcell. "' bgcolor='#". $bg_fill. "'> </td>\n"; 
                }
            }
            /*== Sunday start week with <tr> ==*/ 
            else { 
                echo "<tr bgcolor='#". $bg_tabl. "'>\n";
            } 
            $firstweek = false;
        }
        /*== check for event ==*/   
        echo "<td style='". $tcell. "' ";
        // is this day 'today' AND there's no event today
        if (($ty==$y) && ($tm==$m) && ($td == $d) && (!$ev_dat[$d])) { 
            echo "bgcolor='#". $bg_now. "'>". $d;
        }
        elseif ($ev_dat[$d]) {
            // get what's happening that day and use as 'mouseOver' for the link
            $query = "SELECT * FROM $db_table WHERE id=$ev_dat[$d] ";
            $result = mysql_query($query); 
            $ev = mysql_fetch_array($result);
            $titl = $ev['ev_title'];
            echo "bgcolor='#". $bg_act. "'>";
            $url = "../members/diary/show.php?event=". $ev_dat[$d]. "&sho=". $win_sho;
          
                 echo "<a href=' $url' rel=\"facebox\" title=\"". $titl. "\">". $d. "</a>";
           
        }
        else {
            echo "bgcolor='#". $bg_days. "'>". $d; 
        }
        echo "</td>\n"; 
    
        /*== Saturday end week with </tr> ==*/ 
        if ($wday==6) {
            echo "</tr>\n"; 
        }
        $wday++; 
        $wday = $wday % 7; 
        if (($wday==0) AND ($d!=$lastday)){ echo "<tr bgcolor='#". $bg_tabl. "'>\n"; }
            $d++; 
        }
        // and close off the table
        if (($wday!=7) AND ($wday!=0)) {
            for ($i=$wday; $i<=6; $i++) {
                echo "<td style='". $tcell. "' bgcolor='#". $bg_fill. "'> </td>\n";
            }
            echo "</tr>";
        } 
    echo "\n</table>"; 
    include("win_open.php");
    ?> 

  3. humm ok i now have a problem with displayign the events under the calander

     

    <?php 
    $ev_dat = array();
    for ($i=0;$i<32;$i++) {
        $ev_dat[$i]=0;
    }
    
    $now = date("Y-m-d", time());
    list($ty, $tm, $td) = explode('-',$now); // ty=thisyear, etc. used for highlighting 'today'
    
    include("cal_parms.php"); // assorted configuration variables
    include($dat_names); // retrieved from cal_parms.php as a 'language' file
    
    if (!isset($_GET['m'])) { 
        $m = date("m",mktime()); 
    } else {
        $m = $_GET['m'];
    }
    if (!isset($_GET['y'])) {
        $y = date("Y",mktime());
    } else {
        $y = $_GET['y'];
    }
    
    /*== get what weekday the first is on ==*/ 
    $tmpd = getdate(mktime(0,0,0,$m,1,$y)); 
    $month = $tmpd["month"]; 
    $firstwday= $tmpd["wday"]; 
    if ($firstDayIsMonday == 1) {
    if ($firstwday == 0) {
    	$firstwday = 6;
    } else {
    	$firstwday--;
    }
    }
    $lastday = mk_getLastDayofMonth($m,$y); 
    
    /*== get the last day of the month ==*/ 
    function mk_getLastDayofMonth($mon,$year) 
    {
        for ($tday=28; $tday <= 31; $tday++) 
        {
            $tdate = getdate(mktime(0,0,0,$mon,$tday,$year)); 
            if ($tdate["mon"] != $mon) 
            { 
                break;
            }
        }
        $tday--; 
        return $tday; 
    }
      
    // compute range of dates for this month to match dates in database in the format yyyy-mm-dd
    if (strlen($m)<2) {
        $q="0";
        $q.=$m;
    }
    else {
        $q = $m;
    }	
    $dats_beg = $y. "-". $q. "-01";
    $dats_en = $lastday. "-". $q. "-".$y ;
      
    // open db conn and select all records where date is between $dats_beg and $dats_en
    include("cal_db_conn.php");
    mysql_connect($db_host, $db_login, $db_pass) or die ("Can't connect!"); 
    mysql_select_db($db_name) or die ("Can't open database!"); 
    $query = "SELECT * FROM $db_table WHERE (ev_dat>='$dats_beg') AND (ev_dat<='$dats_en') "; 
      
    $result = mysql_db_query($db_name, $query); ?> 

     

    instead of gaining the months form the db as / compute range of dates for this month to match dates in database in the format yyyy-mm-dd

     

    they are now stored as dd-mm-yyyy so what would i need to chnage to find this?

     

     

  4. ok so for my form im getting users to entre the date in the db via textbox...

     

    im using the date validation shown below

     

    <?php function goof_check($dat,$titl,$locn,$desc,$itsok)
    {
      GLOBAL $itsok;
      $goof_msg = ""; // clear error message string on entry  
      // pseudo-check on date information
      $pieces = explode("-", $dat);
      $yy = strlen($pieces[0]);
      $mm = strlen($pieces[1]);
      $dd = strlen($pieces[2]);
      if (($dd<2)|| ($mm<2) || ($yy<4) )
      {
        $goof_msg = "Date error: yyyy-mm-dd format is required boss<br />";
      }
      
    // if (strlen($titl)<10)  { $goof_msg.="Title is too short<br />"; }
      //if (strlen($locn)<10)  { $goof_msg.="Location is too short<br />"; }
      if (strlen($desc)<10)  { $goof_msg.="Event description is too short<br />"; }
      
      if ($goof_msg)
      { 
        echo "<p><font color='#cc3333'><strong>Data Entry Error[s]</strong></font><br>". $goof_msg. "</font></p>";  
        $itsok = "0";
      }
      return $itsok;
    } ?>

     

    but if i add the date as how i would like it  dd-mm-yy i get the error... the only way its letitng me entre it is via yyy-mm-dd  ,  my question is how cna i chnage this?

  5.  <?php
       
       $userid = $_SESSION['SESS_USERID'];
            if(isset($_POST['submit'])){
              if (isset ($_FILES['new_image'])){
                                      $file_name = $_FILES['new_image']['name'];
                                    $getExt = explode ('.', $file_name);
                    $file_ext = $getExt[count($getExt)-1];
                                    // Adding extension verification
                                    $allowed_ext = "|jpg|png|gif|jpeg|svg|bmp|";
    if (strpos($allowed_ext, "|".strtolower($file_ext)."|")===false) 
      die("Extension: $file_ext is not allowed!");             
                                    // End extension verification           
                                    $imagename = "mainpic.jpg";
                                    
                  $source = $_FILES['new_image']['tmp_name'];
                  $target = "C:/wamp/www/fanjunky/temp/$userid";
                              
                  move_uploaded_file($source, $target);
    
                  $imagepath = $imagename;
                  $save =  "C:/wamp/www/fanjunky/users/$userid/$imagepath"; //This is the new file you saving
                  $file =  "C:/wamp/www/fanjunky/temp/$userid/$imagepath"; //This is the original file
    
                  list($width, $height) = getimagesize($file); 
    
                  // Adding proportionate image resizing, with max values
                              
                      //  $modwidth = 200; $diff = $width / $modwidth; $modheight = $height / $diff; 
                 
                              
                              $max_w = 120;
                              $max_h = 120;
                              
                              if($width <= $max_w && $height <= $max_h){ // if it fits
                         $modheight = $height; 
                                     $modwidth = $width;
                              }else{ // Then resize
                                    $diff = ($width > $height) ? ($width/$max_w) :  ($height/$max_h); // Check which is bigger, and fit it to that max value. This will prevent stretching (80x800)
                        $modheight = $height / $diff; 
                                    $modwidth = $width / $diff;
                              }
                              
                              // End 
                              
                              $tn = imagecreatetruecolor($modwidth, $modheight) ; 
                  $image = imagecreatefromjpeg($file) ; 
                  imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 
                              imagejpeg($tn, $save, 100) ; 
    
                
                             
                 
              }
            }
    ?>

     

     

    try that

  6. [code<form action="<?php echo $_server['php-self'];  ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm">
            <input name="new_image" id="new_image" size="30" type="file" class="fileUpload" />
            <button name="submit" type="submit" class="submitButton">Upload/Resize Image</button>
    </form>
    <?php
            if(isset($_POST['submit'])){
              if (isset ($_FILES['new_image'])){
                                      $file_name = $_FILES['new_image']['name'];
                                    $getExt = explode ('.', $file_name);
                    $file_ext = $getExt[count($getExt)-1];
                                    // Adding extension verification
                                    $allowed_ext = "|jpg|png|gif|jpeg|svg|bmp|";
    if (strpos($allowed_ext, "|".strtolower($file_ext)."|")===false) 
      die("Extension: $file_ext is not allowed!");             
                                    // End extension verification           
                                    $imagename = "mainpic.jpg";
                                    
                  $source = $_FILES['new_image']['tmp_name'];
                  $target = "images/$id.$file_ext";
                              
                  move_uploaded_file($source, $target);
    
                  $imagepath = $imagename;
                  $save = "what ever the user path is" . $imagepath; //This is the new file you saving
                  $file = "what ever the user path is" . $imagepath; //This is the original file
    
                  list($width, $height) = getimagesize($file) ; 
    
                  // Adding proportionate image resizing, with max values
                              
                              /*
                              $modwidth = 200; 
    
                  $diff = $width / $modwidth;
    
                  $modheight = $height / $diff; 
                  */
                              
                              $max_w = 120;
                              $max_h = 120;
                              
                              if($width <= $max_w && $height <= $max_h){ // if it fits
                         $modheight = $height; 
                                     $modwidth = $width;
                              }else{ // Then resize
                                    $diff = ($width > $height) ? ($width/$max_w) :  ($height/$max_h); // Check which is bigger, and fit it to that max value. This will prevent stretching (80x800)
                        $modheight = $height / $diff; 
                                    $modwidth = $width / $diff;
                              }
                              
                              // End 
                              
                              $tn = imagecreatetruecolor($modwidth, $modheight) ; 
                  $image = imagecreatefromjpeg($file) ; 
                  imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 
                              imagejpeg($tn, $save, 100) ; 
    
                
                              $sql = "UPDATE `where ever u stored the pic` SET image = 'mainpic.jpg;
    mysql_query($sql) or die(mysql_error());
                              
                echo "<center>
    <table width=\"50%\" cellspacing=\"0\" cellpadding=\"0\">
      <tr>
        <td width=\"4%\"><img src='images/thumbs/".$imagepath."'></td>
      </tr>
    </table>
    </center>"; 
                 
              }
            }

  7. humm it not working :(

     

    ok in db i have this

     

                                          event start                          event finish

    6  testing event  2009-04-11 10:00:00  2009-04-11 11:00:00

     

    $sql = "SELECT * FROM events WHERE e_start='$d-$m-$y'";
    	echo $sql;
    $postsresult = mysql_query($sql);
    $row = mysql_fetch_array($postsresult);
    
    	if($row['event'] != '')
    {
        echo "<td class='tcell'>";
            echo "<a href=\"http://www.runningprofiles.com/test2.php?month=$d-$m-$y\" rel=\"facebox\" onClick=\"document.f.eventdate.value='$m-$d-$y';\">$d</a>";
            echo "</td>\n";
    }
    else
    {
        echo "<td class='tcell'>";
            echo "$d";
            echo "</td>\n";
    }

     

     

    what am i doing wrong

     

     

     

    and soak thats just gone right over my head lol

  8. here is a link http://www.runningprofiles.com/members/calendar/test.php#

    so here is my db

     

    CREATE TABLE IF NOT EXISTS `events` (
      `e_id` int(99) NOT NULL auto_increment,
      `e_event` varchar(50) NOT NULL default '',
      `e_start` datetime default NULL,
      `e_end` datetime default NULL,
      PRIMARY KEY  (`e_id`),
      KEY `e_start` (`e_start`,`e_end`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

     

     

    so what i want to know is... how can i see if the date on the calander has a event... if so show a link if not show text.

     

    the bold green part is what i cant figure outlol

  9. ok i have got my form to enter tiem and date of a race

    <form name="f" method="POST">
      <table cellpadding="0" cellspacing="0" border="0" bgcolor="#000000"><tr><td>
        <table cellpadding="4" cellspacing="1" border="0 "bgcolor="#FFFFFF">
          <tr><td colspan="2" bgcolor="#000000"><font size="+1" color="#FFFFFF"><b>Add New Event</b></font></td></tr>
          <tr><td><b>Event Start Date: </b></td><td><input type="text" name="eventdate" value="" size="12"> <font size="2">mm/dd/yyyy</font></td></tr>
              <tr><td><b>Event Start: </b></td><td><input name="start" size="6"/><font size="2">00:00</font></td></tr>
              <tr><td><b>Event finish Date: </b></td><td><input type="text" name="eventdate" value="" size="12"> <font size="2">mm/dd/yyyy</font></td></tr>
              <tr><td><b>Event Finish: </b></td><td><input name="finish" size="6" /><font size="2">00:00</font></td></tr>
              <tr><td><b>Event:</b></td><td><input type="text" name="event" size="35" maxlength="128"></td></tr>
          <tr><td colspan="2" align="center" bgcolor="#CCCCCC"><input type="button" name="Submit" value="OK" onClick="javascript: formget2(this.form, 'http://www.runningprofiles.com/members/calendar/addevent.php');"> </td></tr>
            </table></td></tr></table></form>

     

    how can i add both the dates and time together using strtotime() ??

     

    so then i can call from my db like this

     

    $iso_8601_date_time_string = date('Y-m-d', strtotime("April 17, 2009"));

    $sql = "SELECT e_id FROM events WHERE '$iso_8601_date_time_string' BETWEEN e_start AND e_end";

     

  10. sql = "SELECT * FROM events WHERE date='$d-$m-$y'";
    	echo $sql;
    $postsresult = mysql_query($sql);
    $row = mysql_fetch_array($postsresult);

     

    from the code above how could i find out if row['event'] from each day of the month had a result...

     

    so...

     

    Su M  T W  Th F  Sa

    1 2 3 4

    5 6 7 8 9 10 11

    12 13 14 15 16 17 18

    19 20 21 22 23 24 25

    26 27 28 29 30

     

    if the above is my calander and the 16th had an event i would want to show it by producing 16th with a link as it shows.

     

    im just stuggling how to see if there is a result for each day itself

     

    here is all my code for the calander

     

    <script src="http://www.runningprofiles.com/jquery.js" type="text/javascript"></script>
    <link href="http://www.runningprofiles.com/members/calendar/facebox/facebox.css" media="screen" rel="stylesheet" type="text/css"/>
    <script src="http://www.runningprofiles.com/members/calendar/facebox/facebox.js" type="text/javascript"></script> 
    <script>
    jQuery(document).ready(function($) {
      $('a[rel*=facebox]').facebox()
    }) </script>
    
    <?php
    include '../../settings.php';
    
    
    
    mk_drawCalendar($_GET['m'],$_GET['y']); 
      $m = (!$m) ? date("m",mktime()) : "$m";
        $y = (!$y) ? date("Y",mktime()) : "$y";
    //*********************************************************
    // DRAW CALENDAR
    //*********************************************************
    /*
        Draws out a calendar (in html) of the month/year
        passed to it date passed in format mm-dd-yyyy 
    */
    function mk_drawCalendar($m,$y)
    {
        if ((!$m) || (!$y))
        { 
            $m = date("m",mktime());
            $y = date("Y",mktime());
        }
    
        /*== get what weekday the first is on ==*/
        $tmpd = getdate(mktime(0,0,0,$m,1,$y));
        $month = $tmpd["month"]; 
        $firstwday= $tmpd["wday"];
    
        $lastday = mk_getLastDayofMonth($m,$y);
    
    ?>
    <div align="center">
      <table cellpadding="2" cellspacing="0" border="1">
        <tr><td colspan="7" bgcolor="#00CCCC">
          <table cellpadding="0" cellspacing="0" border="0" width="100%">
            <tr><th width="20"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?m=<?=(($m-1)<1) ? 12 : $m-1 ?>&y=<?=(($m-1)<1) ? $y-1 : $y ?>"><<</a></th>
            <th bgcolor="#00CCCC"><font size=2><?="$month $y"?></font></th>
            <th width="20"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?m=<?=(($m+1)>12) ? 1 : $m+1 ?>&y=<?=(($m+1)>12) ? $y+1 : $y ?>">>></a></th>
            </tr></table>
        </td></tr>
        
        <tr><th width=22 class="tcell">Su</th><th width=22 class="tcell">M</th>
          <th width=22 class="tcell">T </th><th width=22 class="tcell">W</th>
          <th width=22 class="tcell">Th</th><th width=22 class="tcell">F</th>
          <th width=22 class="tcell">Sa</th></tr>
        
        <?php $d = 1;
        $wday = $firstwday;
        $firstweek = true;
    
        /*== loop through all the days of the month ==*/
        while ( $d <= $lastday) 
        {
    
            /*== set up blank days for first week ==*/
            if ($firstweek) {
                echo "<tr>";
                for ($i=1; $i<=$firstwday; $i++) 
                { echo "<td><font size=2> </font></td>"; }
                $firstweek = false;
            }
    
            /*== Sunday start week with <tr> ==*/
            if ($wday==0) { echo "<tr>"; }
    
            /*== check for event ==*/  
    	$sql = "SELECT * FROM events WHERE date='$d-$m-$y'";
    	echo $sql;
    $postsresult = mysql_query($sql);
    $row = mysql_fetch_array($postsresult);
    $num = mysql_num_rows($postsresult);
    	if($row['event'] == 1)
        { echo "<td class='tcell'>";
            echo "<a href=\"http://www.runningprofiles.com/test2.php?month=$d-$m-$y\" rel=\"facebox\" onClick=\"document.f.eventdate.value='$m-$d-$y';\">$d</a>";
            echo "</td>\n";
    
    }
    
    else {echo "<td class='tcell'>";
            echo "<a href=\"1\" rel=\"facebox\" onClick=\"document.f.eventdate.value='$m-$d-$y';\">$d</a>";
            echo "</td>\n";}
           
    
            /*== Saturday end week with </tr> ==*/
            if ($wday==6) { echo "</tr>\n"; }
    
            $wday++;
            $wday = $wday % 7;
            $d++;
        }
    ?>
        
        </tr>
      </table>
      Please select the date your event is held on.
      <br />
      
      <?php
    /*== end drawCalendar function ==*/
    } 
    
    
    
    
    /*== get the last day of the month ==*/
    function mk_getLastDayofMonth($mon,$year)
    {
        for ($tday=28; $tday <= 31; $tday++) 
        {
            $tdate = getdate(mktime(0,0,0,$mon,$tday,$year));
            if ($tdate["mon"] != $mon) 
            { break; }
    
        }
        $tday--;
    
        return $tday;
    }
    
    ?>
    </div>
    

  11. i cant get my head round this lol

     

    <?php $sql = "SELECT * FROM events WHERE date='$d-$m-$y'";
    	echo $sql;
    $postsresult = mysql_query($sql);
    $row = mysql_fetch_array($postsresult);
    $num = mysql_num_rows($postsresult);
    	if($row['event'] == 1)
        { echo "<td class='tcell'>";
            echo "<a href=\"http://www.runningprofiles.com/test2.php?month=$d-$m-$y\" rel=\"facebox\" onClick=\"document.f.eventdate.value='$m-$d-$y';\">$d</a>";
            echo "</td>\n";
    
    }
    
    else {echo "<td class='tcell'>";
            echo "<a href=\"1\" rel=\"facebox\" onClick=\"document.f.eventdate.value='$m-$d-$y';\">$d</a>";
            echo "</td>\n";}?>

     

    baiscly if $row['event'] has a event under it during that date then i want to display i link.. but if not the just text $d....

     

    i canty figure out this part though lol if($row['event'] == 1)  how would i find number of results for that row?

  12. i put it in quotes and still nothin...

     

    <?php
    include 'settings.php'; 
    $yes=$_GET['month'];
    
    $sql = "SELECT * FROM events WHERE date='$yes'";
    $postsresult = mysql_query($sql);
    
    
    // IF mysql_query() RETURNS FALSE, THERE IS DIAGNOSTIC INFORMATION AVAILBALE
    if (!postsresult)
    {
       $errmsg = mysql_errno() . ' ' . mysql_error();
       echo "<br/>QUERY FAIL: ";
       echo "<br/>$sql <br/>";
       die($errmsg);
    }
    $row = mysql_fetch_array($postsresult);
    echo $yes;
    echo '<br>';
    echo $row['event'];
    ?>

     

    the output said nothin of errors :S

  13. i really cant figure out what im doing wrong here

    in my db i have a time set as:04-15-2009...

     

    my sql output is:SELECT * FROM events WHERE date=04-15-2009

     

    but when i look on the page i get nothing

    <?php
    include 'settings.php'; 
    $yes=$_GET['month'];
    
    $sql = "SELECT * FROM events WHERE date=$yes";
    
    $postsresult = mysql_query($sql);
    // IF mysql_query() RETURNS FALSE, THERE IS DIAGNOSTIC INFORMATION AVAILBALE
    $num = mysql_num_rows($postsresult);
    
    while($row = mysql_fetch_assoc($postsresult)) {
    if($num < 1)
        { 
    echo $row['event'];}
    else
    { echo 'no events';}
    }
    ?>

×
×
  • 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.