$result = mysql_query($query); $num = mysql_num_rows($result); if ($num > 0) { $first = true; while ($row = mysql_fetch_array($result)) { $traveltime = travelTime($sid, $row[loc], $pid, $id); if ($traveltime > 0) { if ($first) { $first = false; echo '<br>Select a fleet to move to this planet.<br><br><table cellspacing=5> <tr> <td></td> <td>Fleet</td> <td><select name="fleet">'; } echo '<option value="' . $row[id] . '">' . $row[name] . ' [' . fleetSize($sid, $row[id]) . '] ' . floor($traveltime - time()) . '</option>'; } } if (!$first) { echo '<td><input type="submit" value="Send Fleet"></td> </tr> </table>'; } else { echo '<br>You have no fleets that can reach this planet.'; } } else { echo '<br> <table cellspacing=5> <tr> <td></td> <td>You do not control any fleets located on any other planet.</td>
$result = mysql_query($query); while ($row = mysql_fetch_array($result)) { echo '<tr> <td><a href="./fname.php?id=' . $row[id] . '">' . $row[name] . '</a></td>'; //Print the planet name if on a planet or traveling if traveling if ($row[destination] > 0) { if (landFleet($sid, $row[id])) { echo '<td><a href="./planetdetails.php?id=' . $row[destination] . '">' . getPlanetStat(name, $sid, $row[destination]) . '</a></td>'; } else { echo '<td>Traveling</td>'; } } else { echo '<td><a href="./planetdetails.php?id=' . $row[loc] . '">' . getPlanetStat(name, $sid, $row[loc]) . '</a></td>'; } //Continue printing echo '<td>' . fleetSize($sid, $row[id]) . '</td>'; if (getFleetStat(destination, $sid, $row[id]) > 0) { $timeleft = timeLeft($row[destinationtime]); echo '<td><a href="./planetdetails.php?id=' . $row[destination] . '">' . getPlanetStat(name, $sid, $row[destination]) . '</a></td>'; if ($timeleft > 0) { echo '<td>' . $timeleft . '</td>'; } else { echo '<td>In Combat</td>'; } } else { echo '<td align="center">None</td> <td align="center">---</td>'; } echo '<td><a href="./fleetdetails.php?id=' . $row[id] . '">Details</a></td>'; echo '<td><a href="./fleet.php?d=' . $row[id] . '">X</a></td>'; }
function moveFleet($fid, $sid, $pid, $did) { //Pid is the planet coming from //Did is the destination id //Make sure the fleet has size if (fleetSize($sid, $fid) == 0) { return -1; } //Make sure the travel time is not -1, which means cant be visited $travelTime = travelTime($sid, $pid, $did, getFleetStat(ownerid, $sid, $fid)); if ($travelTime < 1) { return -2; } //Set variables setFleetStat(destination, $did, $sid, $fid); setFleetStat(destinationtime, $travelTime, $sid, $fid); setFleetStat(inport, 0, $sid, $fid); //Check if they are going to be in combat, change combat id if (getPlanetStat(ownerid, $sid, $did) > 0 && getPlanetStat(ownerid, $sid, $did) != getFleetStat(ownerid, $sid, $fid)) { setFleetStat(combatid, 1, $sid, $fid); } return 1; }