title: how to enter events for every third friday of every month in php/mysql
body: <p>I'm trying the code below to enter events into <code>MySQL</code> table using <code>PHP</code>. When I run it, it gives no error and no row is inserted into <code>MySQL</code> table. Where am I going wrong in the code?</p>
  
  <p>Also when I change </p>
  
  <pre><code>$date = strtotime("third friday of $month[$j] $year[$i]");
  </code></pre>
  
  <p>to</p>
  
  <pre><code>$date = mktime(0,0,0,$month[$j],$k,$year[$i]);
  </code></pre>
  
  <p>it works for all days, but I'm looking for only third friday of every month..</p>
  
  <pre><code>&lt;?php 
  if(isset($_POST['myform'])){
  
           $day   =   array('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','31');
           $month =   array('1','2','3','4','5','6','7','8','9','10','11','12');              
           $year  =   array('2011', '2012','2013', '2014', '2015', '2016');   
  
           $startday   = $_POST['day'];
           $eventplace = $_POST['eventplace'];
           $eventname  = $_POST['eventname'];
           $eventtime  = $_POST['eventtime'];
  
          for($i=0; $i&lt;count($year); $i++){
  
              for($j=0; $j&lt;count($month); $j++){
  
                  for($k=$startday; $k&lt;count($day); $k = $k + 7){
  
                          $date = strtotime("third friday of $month[$j] $year[$i]");
  
                          $week = date('W', $date) ;
  
    $query = mysql_query(" INSERT INTO caldemo(day, month, year, eventname, eventtime, eventplace, eventweek)
                           VALUES ('".$k."', '".$month[$j]."', '".$year[$i]."', '".$eventname."', '".$eventtime."', '".$eventplace."', '".$week."' )")or die(mysql_error()) ;
                }
              }
           } 
        }
  ?&gt;   
  
  
  &lt;form name="theform" method="post" action="caldemo.php"&gt;
  &lt;table&gt;
  &lt;tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Event Venue:&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="eventplace" size="50"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Event Name:&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="eventname" size="50"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Event Time:&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="eventtime" size="50"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;/td&gt;
  &lt;td&gt;
  &lt;input type="submit" value="Send" name="myform"&gt;
  &lt;/form&gt;
  </code></pre>