CV 데이터베이스가 있습니다. 아래 필드를 볼 수 있으며 꽤 표준입니다. 검색은 SQL 데이터베이스에 정보를 보내는 간단한 양식으로 수행됩니다.정렬 및 페이지 매김, SQL이있는 PHP
내받은 편지함에 500 명이 넘는 지원자가 넘칠 때까지 간단한 시스템에 만족했습니다. 내 이전 시스템은 영원히 찍은 하나씩 하나씩 지원자를 볼 수있었습니다 ...
내가 뭘 하려는지 간단한 백엔드 페이지보기의 phpmyadmin과 비슷한 페이지입니다. (필자는 phpmyadmin을 사용하고 싶지 않습니다. 다른 직원에게 CV 선별 작업을 제공하고 싶습니다.)
기본적으로 개념은 탁월한 테이블을 표시하고 헤더를 클릭하여 정렬을 허용합니다. [페이지 당 20 행] 및 행을 삭제하는 확인란.
나는이 문제를 알아 내려고 노력에 노력을 많이 넣어 가지고 일부 도움을 요청하여 확인 해요)
는지금까지 내가있어 무엇 :
소팅은 아무 문제가 작동하지 않습니다 , 헤더 중 하나를 클릭하면 주소 표시 줄에 localhost/mena/new3.php? sort = fname이 나오고 올바른 Sql 쿼리를 구문 분석하고 페이지를 정렬합니다.
페이지 매김은 작동하지 않습니다. 이 페이지에는 815 명의 후보자가 모두 표시됩니다. 주소 표시 줄의 결과를 클릭하면 localhost/new3.php? page = 2로 변경되지만 0으로 변경되는 번호가 매겨진 링크 1-42가 제공됩니다. 또한
내 인생 내가 PHP는이에 삭제 포함하는 방법을 볼 수 없습니다 ..
이9 그것의 요 의사 코드 아이디어는 다음과 같습니다
//Input the rows from SQL
While($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td> $checkbox1
if checkbox1=true then mysqli_query($con,"DELETE FROM cv WHERE .$row[].");
echo "<td>" . $row['title'] .
내 코드 지금까지 :
<?php
$con=mysqli_connect("localhost","root","","test_db-jil");
// Check connection
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// Pagination
if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; };
$start_from = ($page-1) * 20;
// Sort, from headers.
if(isset($_REQUEST['sort'])){
if($_GET['sort'] == "title"){
$result = mysqli_query($con,"SELECT * FROM cv ORDER BY title");
}
elseif($_GET['sort'] == "fname"){
$result = mysqli_query($con,"SELECT * FROM cv ORDER BY fname");
}
elseif($_GET['sort'] == "lname"){
$result = mysqli_query($con,"SELECT * FROM cv ORDER BY lname");
}
elseif($_GET['sort'] == "gender"){
$result = mysqli_query($con,"SELECT * FROM cv ORDER BY gender");
}
elseif($_GET['sort'] == "dob"){
$result = mysqli_query($con,"SELECT * FROM cv ORDER BY dob");
}
elseif($_GET['sort'] == "nationality"){
$result = mysqli_query($con,"SELECT * FROM cv ORDER BY nationality");
}
elseif($_GET['sort'] == "language"){
$result = mysqli_query($con,"SELECT * FROM cv ORDER BY language");
}
elseif($_GET['sort'] == "phone"){
$result = mysqli_query($con,"SELECT * FROM cv ORDER BY phone");
}
elseif($_GET['sort'] == "email"){
$result = mysqli_query($con,"SELECT * FROM cv ORDER BY email");
}
elseif($_GET['sort'] == "uni"){
$result = mysqli_query($con,"SELECT * FROM cv ORDER BY uni");
}
elseif($_GET['sort'] == "prog"){
$result = mysqli_query($con,"SELECT * FROM cv ORDER BY prog");
}
elseif($_GET['sort'] == "graddate"){
$result = mysqli_query($con,"SELECT * FROM cv ORDER BY graddate");
}
elseif($_GET['sort'] == "startdate"){
$result = mysqli_query($con,"SELECT * FROM cv ORDER BY startdate");
}
elseif($_GET['sort'] == "grad"){
$result = mysqli_query($con,"SELECT * FROM cv ORDER BY grad");
}
else{
$result = mysqli_query($con,"SELECT * FROM cv ORDER BY fname");
}
}
else{ // Default if no parameters passed
$result = mysqli_query($con,"SELECT * FROM cv");
}
//Table of Content
echo "<table border='1'>
<tr>
<th><a href=new3.php?sort=title>Title</a></th>
<th><a href=new3.php?sort=fname>First Name</a></th>
<th><a href=new3.php?sort=lname>Last Name</a></th>
<th><a href=new3.php?sort=gender>Gender</a></th>
<th><a href=new3.php?sort=dob>Date Of Birth</a></th>
<th><a href=new3.php?sort=nationality>Nationality</a></th>
<th><a href=new3.php?sort=language>Language</a></th>
<th><a href=new3.php?sort=phone>Phone No</a></th>
<th><a href=new3.php?sort=email>Email</a></th>
<th><a href=new3.php?sort=uni>University</a></th>
<th><a href=new3.php?sort=prog>Program</a></th>
<th><a href=new3.php?sort=graddate>Graduated</a></th>
<th><a href=new3.php?sort=startdate>Start Date</a></th>
<th><a href=new3.php?sort=grad>Applying for</a></th>
<th>CV File</th>
</tr>";
//Input the rows from SQL
While($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['title'] . "</td>";
echo "<td>" . $row['fname'] . "</td>";
echo "<td>" . $row['lname'] . "</td>";
echo "<td>" . $row['gender'] . "</td>";
echo "<td>" . $row['dob'] . "</td>";
echo "<td>" . $row['nationality'] . "</td>";
echo "<td>" . $row['language'] . "</td>";
echo "<td>" . $row['phone'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['uni'] . "</td>";
echo "<td>" . $row['prog'] . "</td>";
echo "<td>" . $row['graddate'] . "</td>";
echo "<td>" . $row['startdate'] . "</td>";
echo "<td>" . $row['grad'] . "</td>";
echo "<td><a href=" . $row['cvfilename'] .">" . $row['cvfilename'] ."</a></td>";
echo "</tr>";
}
echo "</table>";
//Get total count of rows then ceil divide by 20 as pages
$sql = "SELECT COUNT(*) as 'num' FROM cv";
$total_pages = $con->query($sql) or die(mysqli_error($connection));
$row = $total_pages->fetch_assoc();
$total_pages = ceil($row['num']/20);
for ($i=1; $i<=$total_pages; $i++) {
//Can I ?page= and ?sort= ??????
echo "<a href='new3.php?page=".$i."'>".$i."</a> ";
};
mysqli_close($con);
?>
다시 작성하여 페이지 매기기를 수정하고 정렬 작업을 수행하고 마지막으로 각 행에 삭제 확인란을 추가하십시오. :)
http://stackoverflow.com/a/8255054/285587을 시작하려는 곳 –