第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

php 檢查 url 中是否存在變量并替換值

php 檢查 url 中是否存在變量并替換值

PHP
達(dá)令說 2023-11-05 15:42:01
我寫了一個(gè)函數(shù),允許我進(jìn)行分頁(yè)。問題來了:當(dāng)我單擊按鈕將頁(yè)面更改為 URL 時(shí),會(huì)添加許多相同的值,如下所示:時(shí)事通訊.php?action=sent-emails&page=2&page=1&page=4&page=5&page=7&page=5&page=1function pagination($sql_general,$page_name_pagination,$page_query_pagination) {  require $_SERVER['DOCUMENT_ROOT'] . 'it/intranet/includes/dbh.inc.php';  $sql1 =  $sql_general;  $sql1_query = mysqli_query($conn, $sql1);  $total = mysqli_num_rows($sql1_query);  $adjacents = 3;  $targetpage = $page_name_pagination; //your file name  if (!empty($page_query_pagination)) {    $targetpage .= "?" . $page_query_pagination . "&page=";  } else {    $targetpage .= "?page=";  }  $limit = 10; //how many items to show per page  $page = $_GET['page'];  if($page){  $start = ($page - 1) * $limit; //first item to display on this page  }else{  $start = 0;  }  /* Setup page vars for display. */  if ($page == 0) $page = 1; //if no page var is given, default to 1.  $prev = $page - 1; //previous page is current page - 1  $next = $page + 1; //next page is current page + 1  $lastpage = ceil($total/$limit); //lastpage.  $lpm1 = $lastpage - 1; //last page minus 1  $pagination = "";  if($lastpage > 1)  {  $pagination .= "<div class='pagination1'> <ul class='pagination'>";  if ($page > $counter+1) {  $pagination.= "<li class='page-item'><a class='page-link' href=\"$targetpage$prev\"><</a></li>";  }  if ($lastpage < 7 + ($adjacents * 2))  {  for ($counter = 1; $counter <= $lastpage; $counter++)  {  if ($counter == $page)  $pagination.= "<li class='page-item'><a class='page-link' href='#' >$counter</a></li>";  else  $pagination.= "<li class='page-item'><a class='page-link' href=\"$targetpage$counter\">$counter</a></li>";  }  }  elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some  {現(xiàn)在,如何檢查“page=x”是否存在并替換該值?
查看完整描述

1 回答

?
暮色呼如

TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超9個(gè)贊

拆分、修改/添加和撰寫:


parse_str($query_string,$list);

if (isset($list['name'])

{

     // name= exists, modify it

}

else

{

     // name= not exists

     $list['name'] = "new value";

}

$query_string = http_build_query($list);


查看完整回答
反對(duì) 回復(fù) 2023-11-05
  • 1 回答
  • 0 關(guān)注
  • 173 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)