Welcome Guest, Not a member yet? Register   Sign In
Load a foreach statement on page load?


Im hopeful someone may know how to solve this (probably) simple issue im having.

I have a page with a form that enters data into a database table.Next to this form i have a foreach statement which displays the posts that have been entered using the form. (so a basic write and read)

When you initially go to the form page, the list of posts on the right does not load until data has been sent using the webform.

is there a way to load this piece of code everytime the page loads? So that you dont necessarily HAVE to use the form to display existing posts?

<?php if(isset($records)) : foreach($records as $row) : ?>
<h2 class="area_h">&lt;?php echo $row->name; ?&gt;</h2>
Deadline:&lt;?php echo $row->project_deadline; ?&gt;
<h3 class="a_h">&lt;?php echo anchor("site/delete/$row->id", 'Delete post'); ?&gt; </h3>
&lt;?php endforeach; ?&gt;

Thank you!

[eluser]Rok Biderman[/eluser]
Well, untill you put it out from if (isset... conditional that is unlikely to happen. Hope this was enough of a tip Wink


Your tip made me realise the blazing error in my logic!

Many thanks, its all sorted!

Theme © iAndrew 2016 - Forum software by © MyBB