New to php, I have created an html table and convert it to a calendar using php, this is to display my archives in a calendar like table rather than the plain table I’m using now. I created an api to fetch my archived data and consume this over my wordpress site, the data comes in as JSON. The problem is that I can’t find a way to match my urls to the new calendar like table. This is how I currently have my table:

<table>
		   <tr>
		      <th>Created</th>
		      <!--<th>#</th>-->
                      <th>Name</th>
                      <th>Link</th>
		   </tr>
	   	<?php foreach($data1 as $capture){ ?> 
		    		<tr>
					<?php echo '<td>' . $capture->Created . '</td>';?>
					<?php //* echo '<td>' . $capture->ID . '</td>';//*/?>
					<?php echo '<td>' . $capture->FileName. '</td>';?>
		    		<?php echo '<td><a href='. $capture->Url.'>Download</a></td>';?>
                   		</tr>
	  	 <?php
	   		 }?>
		 </table>

This is how my calendar is setup:

 <table class="table table-bordered">
                    <tr>
                        <th>S</th>
                        <th>M</th>
                        <th>T</th>
                        <th>W</th>
                        <th>T</th>
                        <th>F</th>
                        <th>S</th>
                    </tr>
                       <?php 
                            
                        foreach ($weeks as $week){
                            echo $week;                          
                        }
                    
                        ?> 
                </table>
         </div>

I’ve tried a few things like, adding the url at the moment I’m creating the current month and also after both tables have been created by trying to match the Created date to the calendar date but I’ve failed. Any direction you could provide would be really appreciated as I’m currently going down several different rabbit holes and are not too sure how to proceed.

Read more here: php matching json data to html table (calendar)


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: