мне нужно найти способ, чтобы получить HREF, чтобы перейти от этогоHREF/корпус выключатель необходима помощь
<a href='{$_SERVER['PHP_SELF']}?currentpage=1'>First</a> ";
к чему-то вроде
<a href='index.php?menukey=7... then currentpage=1'>First</a>";
Мне нужна постраничная страница, чтобы открыть в коммутаторе . Следующий код - это то, что у меня есть для страницы с разбивкой на страницы. Любая помощь будет оценена по достоинству.
Спасибо
<?php
require_once ('mysqli_connect.php');
$sql = "SELECT COUNT(NewCustomerID) FROM customer";
$result = @mysqli_query($dbc, $sql);
$r = @mysqli_fetch_row($result);
$numrows = $r[0];
$rowsperpage = 10;
// find out total pages
$totalpages = ceil($numrows/$rowsperpage);
// get the current page or set a default
if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
// cast var as int
$currentpage = (int) $_GET['currentpage'];
} else {
// default page num
$currentpage = 1;
} // end if
// if current page is greater than total pages...
if ($currentpage > $totalpages) {
// set current page to last page
$currentpage = $totalpages;
} // end if
// if current page is less than first page...
if ($currentpage < 1) {
// set current page to first page
$currentpage = 1;
} // end if
// the offset of the list, based on current page
$offset = ($currentpage - 1) * $rowsperpage;
$q = "SELECT CONCAT(left(FirstName,1),left(MiddleName,1),LastName) AS UserName,
CONCAT(LastName, ', ', FirstName, ' ', MiddleName) AS Name,
(NewCustomerID) AS customerid,
(OldCustomerID) AS oldcustomerid,
(zlu_birthmonth.Description) AS birthmonth,
(zlu_cars.Description) AS cartype,
(zlu_carcolor.Description) AS carcolor,
(zlu_computers.Description) AS computer,
(zlu_race.Description) AS race,
(zlu_residence.Description) AS residence,
(IsLaptop) AS IsLaptop,
CASE IsLaptop
WHEN '1' THEN 'Yes'
WHEN '0' THEN 'No'
END AS laptop
FROM customer
INNER JOIN zlu_cars ON(customer.CarID = zlu_cars.CarID)
INNER JOIN zlu_birthmonth ON(customer.BirthMonthID = zlu_birthmonth.BirthMonthID)
INNER JOIN zlu_carcolor ON (customer.CarColorID = zlu_carcolor.CarColorID)
INNER JOIN zlu_computers ON (customer.ComputerID = zlu_computers.ComputerID)
INNER JOIN zlu_race ON(customer.RaceID = zlu_race.RaceID)
INNER JOIN zlu_residence ON(customer.ResidenceID = zlu_residence.ResidenceID)
order by NewCustomerID LIMIT $offset, $rowsperpage";
$result = @mysqli_query($dbc, $q); if(!$result){die(mysqli_error($dbc));}
echo '<table border="1">
<tr>
<th>Customer ID</th>
<th>Old Customer ID</th>
<th>Customer Name</th>
<th>UserName</th>
<th>Car</th>
<th>Car Color</th>
<th>Birth Month</th>
<th>Computer Brand</th>
<th>Laptop</th>
<th>Race</th>
<th>Residence</th>
</tr>';
$bg = '#eeeeee'; // set initial back ground color
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
$bg = ($bg =='#eeeeee' ? '#ffffff' : '#eeeeee'); // switch the background color.
echo '<tr bgcolor="' . $bg . '">
<td>' . $row['customerid']. '</td>
<td>' . $row['oldcustomerid']. '</td>
<td>' . $row['Name'].'</td>
<td>' . $row['UserName'].'</td>
<td>' . $row['cartype'].'</td>
<td>' . $row['carcolor'].'</td>
<td>' . $row['birthmonth'].'</td>
<td>' . $row['computer'].'</td>
<td>' . $row['laptop'].'</td>
<td>' . $row['race'].'</td>
<td>' . $row['residence'].'</td>
</tr>'; } // end of while loop
echo '</table>';
?>
<?php
/****** build the pagination links ******/
// range of num links to show
$range = 3;
if($currentpage==1)
{
echo '<span class="prn"> First <<</span> ';
}
if ($currentpage > 1) {
// show << link to go back to page 1
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'>First</a> ";
// get previous page num
$prevpage = $currentpage - 1;
// show < link to go back to 1 page
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'> < </a> ";
} // end if
// loop to show links to range of pages around current page
for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
// if it's a valid page number...
if (($x > 0) && ($x <= $totalpages)) {
// if we're on current page...
if ($x == $currentpage) {
// 'highlight' it but don't make a link
echo " <b>$x</b> ";
// if not current page...
} else {
// make it a link
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> ";
} // end else
} // end if
} // end for
// if not on last page, show forward and last page links
if ($currentpage != $totalpages) {
// get next page
$nextpage = $currentpage + 1;
// echo forward link for next page
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'> > </a> ";
// echo forward link for lastpage
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>Last</a> ";
} // end if
else
{
echo '<span class="prn"> Last >></span> ';
}
/****** end build pagination links ******/
mysqli_close($dbc);
?>
Ваш вопрос не очень понятно, вы имеете в виду, как вы добавить другое значение в ссылке? Например, 'index.php? Currentpage = 1 & menukey = 7' или вам нужна помощь, чтобы получить менуки в первую очередь? – Avanche
Nope Ricardo, добавив index.php? Menukey = 7 к ссылке. –
Все еще не совсем понятно. Я думаю, вы хотите заменить '{$ _SERVER ['PHP_SELF']}? Currentpage = 1' с' index.php? Menukey = 7 & currentpage = 1', так это? – Avanche