This is my full error:
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\bilzar\components\com_blank\views\default\tmpl\default.php on line 14
My code is:
<?php
// Valid execution check
defined('_JEXEC') or die('Restricted Access');
?>
<h1>Blank Component</h1>
<input type="button" class="measure" value="Get New Measurement" />
<table id="thedata">
<thead>
<tr>
<th>Measurement</th><th>Timestamp</th>
</tr>
</thead>
<tbody class="measurements">
<?php foreach($this -> data as $data) : ?>
<?php
$unixTime = strtotime($data->timestamp);
?>
<tr>
<td><?php echo $data->measurement; ?></td><td><?php echo date("d-m-Y H:i:s", $unixTime); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div class="pagination"><?php echo $this->pagination->getPagesLinks(); ?></div>
<script>
window.addEvent('domready', function() {
$$(".measure").addEvent('click', function() {
var request = new Request.JSON(
{
url: 'http://localapache.dyndns.org/joomla_arduino/index.php/blank/sense/sense/raw',
onSuccess: function(e) {
var tr = new Element('tr', {html: '<td>'+e.measurement+'</td><td>'+e.timestamp+'</td>'});
var element = $('thedata').getElement('tbody');
tr.inject(element, 'top');
}
}).get();
});
/*
*/
});
</script>
<style>
table td { padding: 5px; }
input[type=button] { margin:10px 0;}
.pagination ul { list-style-type:none; }
.pagination ul li { float:left; }
</style>
Can anyone help me how I can fix this error?