页面链接不止一个在php搜索分页中不起作用

I want to have a search on my database , and also at the begining , when the search button is not clicked , it shows all the table rows.

The problem is when I do the search. For example: the result has two pages , when I click on page 2 , it shows the page 2 of the entire database table instead of my search result.

////////////////////////////////////pagination/////////////////////////////
$per_page = 20;
if(isset($_GET['page'])) {
$page = $_GET['page'];
}  else {
$page = 1;
 }
$start = $per_page * $page;
$start = $start - $per_page;

if (isset($_POST['search'])) 
{

    $sharh = ($_POST['sharh']);
    $mark = ($_POST['mark']);

    $query = "SELECT * FROM shams_tbl WHERE sharhe_kala='$sharh' OR Mark='$mark'  LIMIT $start , $per_page";
    $result = mysqli_query($db,$query);

    $query2 = "SELECT COUNT(*) as total FROM shams_tbl WHERE sharhe_kala='$sharh' OR Mark='$mark' ";
    $result2 = mysqli_query($db,$query2);
}
else
{
    $query = "SELECT * FROM shams_tbl LIMIT $start , $per_page";
    $result = mysqli_query($db,$query);

    $query2 = "SELECT COUNT(*) as total FROM shams_tbl";
    $result2 = mysqli_query($db,$query2);
}


  echo " <form method='post' enctype='multipart/form-data'>
  <table class='blueTable'><thead><tr><th>شماره</th><th>شرح کالا</th><th>مارک</th><th>تعداد1</th><th>قیمت غیر نقدی 1</th><th>قیمت نقدی 1</th><th>تعداد 2</th><th>قیمت غیرنقدی 2</th><th>قیمت نقدی 2</th><th>تعداد 3</th><th>قیمت غیرنقدی 3</th><th>قیمت نقدی 3</th><th>افزایش قیمت</th></tr></thead>";

  while($row = $result->fetch_assoc())
  {
    echo "<tr><td>".$row["id"]."</td><td>".$row["sharhe_kala"]."</td><td>".$row["Mark"]."</td><td>".$row["tedad1"]."</td><td>".$row["price_gheyrnaqd1"]."</td><td>".$row["price_naqd1"]."</td><td>".$row["tedad2"]."</td><td>".$row["price_gheyrnaqd2"]."</td><td>".$row["price_naqd2"]."</td><td>".$row["tedad3"]."</td><td>".$row["price_gheyrnaqd3"]."</td><td>".$row["price_naqd3"]."</td><td>".$row["Afzayeshqeymat"]."</td></tr>";
  }
  echo "</table></form> ";



$total = mysqli_fetch_assoc($result2);
$total_page = (ceil($total['total'] / $per_page));
echo"<table class='pagination'>";
        $prev = $page-1;
        if($page <=1) {
            echo "
            <td> << </td>
        ";
        }else {
            echo "
            <td><a href=\"?page=".$prev."\"> << </a></td>
        ";
        }

        for($i=1;$i<=$total_page;$i++){

            if($i==$page) {
                echo "
                <td class='active'>$i</td>
            ";
            }
            else {
                echo "
                <td><a href=\"?page=".$i."\">".$i."</a></td>
            ";
            }
        }
        $next = $page+1;
        if($page>=$total_page) {
            echo "
             <td>>></td>
        ";
        } else {
            echo "
             <td><a href=\"?page=$next\"> >></a></td>
        ";
        }
        echo"</table>";

I changed the url to :

 else {
       echo "
       <td><a href=\"?page=".$i."&sharh=".$sharh."&mark=".$mark."\">".$i."</a></td> ";
      }

and add some condition :

if(isset($_GET['mark']) or isset($_GET['mark']))  // if anything in url
    {
    $mark = $_GET['mark'];
    $sharh = $_GET['sharh'];
    } 
else   //first time that search button clicked and there is no url link
    {
    $sharh = ($_POST['sharh']);
    $mark = ($_POST['mark']);
    }
    $query = "SELECT * FROM shams_tbl WHERE sharhe_kala='$sharh' OR Mark='$mark'  LIMIT $start , $per_page";
    $result = mysqli_query($db,$query);

    $query2 = "SELECT COUNT(*) as total FROM shams_tbl WHERE sharhe_kala='$sharh' OR Mark='$mark' ";
    $result2 = mysqli_query($db,$query2);

if ($mark=="" and $sharh=="")   //if not searching
{
    $query = "SELECT * FROM shams_tbl LIMIT $start , $per_page";
    $result = mysqli_query($db,$query);

    $query2 = "SELECT COUNT(*) as total FROM shams_tbl";
    $result2 = mysqli_query($db,$query2);
}