I'm doing very simple pagination and even with isset in place, i'm getting
Notice: Undefined index: page on line 45
. I know what undefine index is, but I have no clue how to fix it in this code because the variable page is triggered in href.
table.php
<?php
$perpage=3;
if(isset($_GET['page'])){
    $page=$_GET['page'];
}
else{
    $page=1;
}
$offset=($_GET['page']-1)*$perpage;
$sql="SELECT* FROM `companystructures` LIMIT ".$offset.",".$perpage."";
$result=mysqli_query($db,$sql);
?>
    <table id="myTable" class="rwd-table table table-striped table-hover tablesorter" >
  <tr>
      <th>ID</th>
    <th>Name</th>
      <th>Description</th>
        <th>Type</th>
    <th>Address</th>
    <th>Country</th>
        <th>Time Zone</th>
  </tr>
  <?php while($company=mysqli_fetch_array($result)){ ?>
  <tr>
      <td data-th="ID"><?=$company['id'];?></a></td>
      <td data-th="Name"><?=$company['title'];?></td>
    <td data-th="Description"><?=$company['description'];?></td>
    <td data-th="Type"><?=$company['type'];?></td>
    <td data-th="Address"><?=$company['address'];?></td>
    <td data-th="Country"><?=$company['country'];?></td>
    <td data-th="Time Zone"><?=$company['timezone'];?></td>
  </tr>
    <?php };?>
</table>
      <div class='col-md-6 pull-right'>
<!-- Pagination -->
            <?php
$sql="SELECT * FROM `companystructures`";
$result=mysqli_query($db,$sql);
$total_rows=mysqli_num_rows($result);
$total_pages=ceil($total_rows/$perpage);
echo "<a href='home.php?page=1'>First</a>";
echo "<span style='margin:5px;'>";
for($i=1;$i<=$total_pages;$i++){
echo "<a href='home.php?page=$i'>$i</a>";
echo "<span style='margin:5px;'>";
}
echo "<a href='index.php?page=$total_pages'>last</a>";
?>
        </div>
