Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Calendar issue
    primarykey
    data
    text
    <p>I have a small issue with a calendar I'm trying to create. It's not outputting my array correctly, any ideas? The numbers aren't coming up for the dates.</p> <p>Here's my main out put file:</p> <pre><code>&lt;?php require('date_class.php'); ?&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Calendar || That sorta works&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Calendar&lt;/h1&gt; &lt;?php echo $date_class-&gt;get_day(); ?&gt; &lt;?php echo $date_class-&gt;get_month(); ?&gt; &lt;?php echo $date_class-&gt;get_year(); ?&gt; &lt;?php $weekdays = array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'); ?&gt; &lt;?php foreach($dates as $month =&gt; $weeks) { ?&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt;&lt;?php echo implode('&lt;/th&gt;&lt;th&gt;', $weekdays); ?&gt;&lt;/th&gt; &lt;/tr&gt; &lt;?php foreach($weeks as $week =&gt; $days){ ?&gt; &lt;tr&gt; &lt;?php foreach($weekdays as $day){ ?&gt; &lt;td&gt; &lt;?php echo isset($days[$day]) ? $days[$day] : '&amp;nbsp'; ?&gt; &lt;/td&gt; &lt;?php } ?&gt; &lt;/tr&gt; &lt;?php } ?&gt; &lt;/table&gt; &lt;?php } ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And here's my class file:</p> <pre><code>&lt;?php class Date_class{ /* Sets our vars within the class */ public $day; public $month; public $year; public $dates; public $syear; /* Sets day */ public function set_day($day){ $this-&gt;day = $day; } /* Sets month */ public function set_month($month){ $this-&gt;month = $month; } /* Sets year */ public function set_year($year){ $this-&gt;year = $year; } /* Sets date */ public function set_date($month, $year){ $this-&gt;date = $day . $month . $year; } /* Sets dates for set year */ public function set_all_dates(){ $this-&gt;dates = $dates; } /* Gets day */ public function get_day(){ return $this-&gt;day; } /* Gets month */ public function get_month(){ return $this-&gt;month; } /* Gets year */ public function get_year(){ return $this-&gt;year; } /* Returns dates for year */ public function get_all_dates($year){ $dates = array(); for($i = 1; $i &lt;= 366; $i++){ $month = date('m', mktime(0,0,0,0,$i,$year)); $wk = date('W', mktime(0,0,0,0,$i,$year)); $wkDay = date('D', mktime(0,0,0,0,$i,$year)); $day = date('d', mktime(0,0,0,0,$i,$year)); $dates[$month][$wk][$day] = $wkDay; } return $dates; } } /* Sets current day as var */ $day = date("d"); /* Sets current month as var */ $month = date("m"); /* Sets current year as var */ $year = date("Y"); /* Creates class as object */ $date_class = new Date_class(); /* Passes our gregorian variables \m/ into our calendar object */ $date_class-&gt;set_day($day); $date_class-&gt;set_month($month); $date_class-&gt;set_year($year); /* Sets calendar year */ $dates = $date_class-&gt;get_all_dates($year); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload