Jump to content

Combing Route and Navdata in foreach Loop


freshJet

Recommended Posts

  • Moderators

Here's what I have so far. No luck... Hopefully someone with a knowledge of it will come by.

<?php
$fromlat = $schedule->deplat;
$fromlng = $schedule->deplng;
$route_string = $schedule->route;
$routedata = NavData::parseRoute($fromlat, $fromlng, $route_string);
$route_string = array();
?>
<table>
<thead>
<tr>
<th>Lat</th>
<th>Long</th>
</tr>
</thead>
<tbody>
<?php
foreach($routedata as $routeline) {
?>
<tr>
<td align="center"><?php echo $routeline->lat; ?></td>
<td align="center"><?php echo $routeline->lng; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>

Link to comment
Share on other sites

Guest lorathon

Here you go

<?php
$params->deplat = 1;
$params->deplng = 1;
$params->route = 'HEL UT6 PEVEN UL990 PERRY';

$routedata = NavData::parseRoute($params);
?>
<table>
<thead>
 <tr>
  <th>Lat</th>
  <th>Long</th>
 </tr>
</thead>
<tbody>
<?php
foreach($routedata as $routeline) {
 ?>
 <tr>
  <td align="center"><?php echo $routeline->lat; ?></td>
  <td align="center"><?php echo $routeline->lng; ?></td>
 </tr>
<?php
}
?>
</tbody>
</table>

Link to comment
Share on other sites

Guest lorathon

So I am confused? Is the loop working at all? It is one my site. If you want the name then just expand the table. The table that Kyle wrote has just the lat/lng but all columns can be put into the table.

Link to comment
Share on other sites

  • Moderators

Still not working for me :/

It worked for me. Did you change code on top and set it where your getting the data.

$params->deplat = 1;
$params->deplng = 1;
$params->route = 'HEL UT6 PEVEN UL990 PERRY';

So, if your doing it in the schedules detail page, this is the code..

<?php
$params->deplat = $schedule->deplat;
$params->deplng = $schedule->deplng;
$params->route = $schedule->route;
$routedata = NavData::parseRoute($params);
?>
<table>
<thead>
 <tr>
  <th>Lat</th>
  <th>Long</th>
 </tr>
</thead>
<tbody>
<?php
foreach($routedata as $routeline) {
 ?>
 <tr>
  <td align="center"><?php echo $routeline->lat; ?></td>
  <td align="center"><?php echo $routeline->lng; ?></td>
 </tr>
<?php
}
?>
</tbody>
</table>

Link to comment
Share on other sites

Nope not working:

<?php
$params->deplat = $schedule->deplat;
$params->deplng = $schedule->deplng;
$params->route = $route;
$routedata = NavData::parseRoute($params);
?>
<table>
<thead>
 <tr>
  <th>Lat</th>
  <th>Long</th>
 </tr>
</thead>
<tbody>
<?php
foreach($routedata as $routeline) {
 ?>
 <tr>
  <td align="center"><?php echo $routeline->lat; ?></td>
  <td align="center"><?php echo $routeline->lng; ?></td>
 </tr>
<?php
}
?>
</tbody>
</table>

Link to comment
Share on other sites

By the way this is in a file called briefing.php in my public_html directory.

Schedule:

$schedule = SchedulesData::GetScheduleDetailed (all I can remember off the top of my head)

$route is $schedule->route but with some characters removed as some of my routes had '?' instead of a space so I used str_replace to do replace that with a space.

Link to comment
Share on other sites

Guest lorathon

Then change this

$params->deplat = $schedule->deplat;
$params->deplng = $schedule->deplng;
$params->route = $route;

to this

$params->deplat = $schedule->deplat;
$params->deplng = $schedule->deplng;
$params->route = $schedule->route;

And then expand the table to show what you wish. The route must be part of the schedule for this to work

Link to comment
Share on other sites

Guest lorathon

If you use this

<?php
$params->deplat = 1;
$params->deplng = 1;
$params->route = 'HEL UT6 PEVEN UL990 PERRY';
$routedata = NavData::parseRoute($params);
?>
<table>
<thead>
 <tr>
  <th>Lat</th>
  <th>Long</th>
 </tr>
</thead>
<tbody>
<?php
foreach($routedata as $routeline) {
 ?>
 <tr>
  <td align="center"><?php echo $routeline->lat; ?></td>
  <td align="center"><?php echo $routeline->lng; ?></td>
 </tr>
<?php
}
?>
</tbody>
</table>

And nothing shows up then there is something wrong. This supplies the start lat/lng and the route. I would check your DB and ensure that the navdata table is there.

Link to comment
Share on other sites

  • Moderators

From what itrobb is saying, I agree and it doesn't look like he has or not have the navdata tables set up or not correct.

Do you have a table like navdata or phpvms_navdata in your database? Double check and if it is empty or not there, then you would need to import one from the latest phpVMS Version.

Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...

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...