Jump to content

Making a Fleet List with Reg and Type Only


freshJet

Recommended Posts

I am trying to create another aircraft list but with registrations and type only, for the maintenance module. I've got this:

<?php foreach $aircraft as $aircraft( ?>
<html>
<table border="1">
<tr>
 <td width="200"><?php echo $aircraft->registration ?></td>
 <td width="200">Last Check</td>
 <td width="200">Next Due</td>
</tr>
</table>
</html>
<?php ) ?>

But get:

Warning: Invalid argument supplied for foreach() in /home/freshje1/public_html/testskin/core/templates/fleet_maintenance.tpl on line 1

Link to comment
Share on other sites

I am trying to create another aircraft list but with registrations and type only, for the maintenance module. I've got this:

<?php foreach $aircraft as $aircraft( ?>
<html>
<table border="1">
<tr>
 <td width="200"><?php echo $aircraft->registration ?></td>
 <td width="200">Last Check</td>
 <td width="200">Next Due</td>
</tr>
</table>
</html>
<?php ) ?>

But get:

Warning: Invalid argument supplied for foreach() in /home/freshje1/public_html/testskin/core/templates/fleet_maintenance.tpl on line 1

Have you created a module file for the template, so you can pull the relevent aircraft data from the database?

Link to comment
Share on other sites

Yes I've done all that. It's a PHP error. What's wrong with the code?

Here's a link: http://www.freshjetvirtual.com/testskin/index.php/fleetmaintenance

Got to be logged in to view

Also, why have you got the <html></html> in the code? That should only be used once on a page, and it's in your layout.tpl and footer files.

EDIT: worth doing a print_r to see if the aircraft data is actually available?

Place this somewhere in the file:

<?php print_r($aircraft);?>

See what that shows

Also try changing this

<?php foreach $aircraft as $ac( ?>

and then amend the $aircraft to $ac in the rest of the code.

Link to comment
Share on other sites

Didn't work. Keep getting errors. Now got:

Parse error: syntax error, unexpected '{', expecting '(' in /home/freshje1/public_html/testskin/core/templates/fleet_maintenance.tpl on line 1

<?php foreach {$aircraft as $ac}?>
<table border="1">
<tr>
 <td width="200"><?php echo $ac->registration ?></td>
 <td width="200">Last Check</td>
 <td width="200">Next Due</td>
</tr>
</table>
<?php } ?>

Link to comment
Share on other sites

My bad, should have posted the code. Here's what I meant:

<?php foreach ($aircraft as $ac){?>
<table border="1">
<tr>
 <td width="200"><?php echo $ac->registration ?></td>
 <td width="200">Last Check</td>
 <td width="200">Next Due</td>
</tr>
</table>
<?php }; ?>

Link to comment
Share on other sites

OK that cleared up slightly, still something wrong with line 1:

Warning: Invalid argument supplied for foreach() in /home/freshje1/public_html/testskin/core/templates/fleet_maintenance.tpl on line 1

That code should work. How are you calling the aircraft data from the db? It's saying invalid argument because there is no $aircraft data available.

Link to comment
Share on other sites

I've added it manually through phpMyAdmin but it won't show in the admin panel or on the site...

When you create a new module (addon), you need to create a function to pull the data from the database using an sql query, or to use an existing function to pull the data. Then you can echo it out in the template (tpl) files. By the sounds of it, you're not pulling any data from the database in the module file, so there's nothing to display in the template file.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...