-1

2 つのファイルがあります。1 つ目は という名前semester_1.phpで、2 つ目は という名前pagination.phpです。サブジェクトの値をに渡してから、クエリして出力しようとしてsemester_1.phppagination.phpます。javascript と Ajax を使用して href の値を取得し、それを別のファイルに渡しましたpagination.php。問題は、表示もエラーもないことです。ここにコードがあります。誰か助けてもらえますか? アクセスする場合は、両方のファイルが同じディレクトリにあることに注意してください。

semester_1.php

<!doctype html>
<html lang="en">
<head>
<style>
.ui-tabs .ui-tabs-nav {
    margin: 0;
    padding: .2em .2em 0;
    height: 30px;
        font-size: 12px;

}
.ui-corner-all,
.ui-corner-bottom,
.ui-corner-right,
.ui-corner-br {
    border-bottom-right-radius: 4px;
    margin-left: 15px;
    height: 520px;
}
</style>
<meta charset="utf-8" />
<title>jQuery UI Tabs - Default functionality</title>
<link rel="stylesheet" href="pagenation.css" type="text/css" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
$( "#tabs" ).tabs();
});
</script>


<script>
$(function(){
    $('div#tabs ul li a').click(function() {
        var n = $(this).attr('href');
        var p = n.slice(5, 6);
        $.ajax({
            type: 'post',
            url: 'pagenation.php',
            data: {value : p},
            success: function(data) {
                // Do something with response 'data'
            }
        });
    });
});
</script>


</head>
<body>
<div id="tabs">
<ul>
<li><a href="#sub=1">Introduction to Programming</a></li>
<li><a href="#sub=2">Fundamental of Programming</a></li>
<li><a href="#sub=3">Afghan History</a></li>
<li><a href="#sub=4">Mathematics</a></li>
<li><a href="#sub=5">Islamic Study</a></li>
<li><a href="#sub=6">English</a></li>
</ul>
<div id="sub=1">
<br><br>
<?php include('pagenation.php');?>
</div>
<div id="sub=2">
<br><br>
<?php include('pagenation.php');?>
</div>
<div id="sub=3">
<br><br>
<?php include('pagenation.php');?>
</div>
<div id="sub=4">
<br><br>
<?php include('pagenation.php');?>
</div>
<div id="sub=5">
<br><br>
<?php include('pagenation.php');?>
</div>
<div id="sub=6">
<br><br>
<?php include('pagenation.php');?>
</div>



</div>
</body>
</html>

ページネーション.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Papermashup.com | PHP Pagination</title>


 <link rel="stylesheet" href="css/pagenation.css" type="text/css" />

</head>

<body>



<?php
$dbhost                         = "localhost";
$dbuser                         = "root";
$dbpass                         = "";
$dbname                         = "LMS";



$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ("Error connecting to database");

mysql_select_db($dbname);
    $tableName="presentation";      
    $targetpage = "Lecture.php";    
    $limit = 10; 

    $query = "SELECT COUNT(*) as num FROM $tableName";
    $total_pages = mysql_fetch_array(mysql_query($query));
    $total_pages = $total_pages[num];

    $stages = 3;
    $page = mysql_escape_string($_GET['page']);
    if($page){
        $start = ($page - 1) * $limit; 
    }else{
        $start = 0; 
        }   

    // Get page data
        $data = $_POST['value'];
    $query1 = "SELECT * FROM $tableName WHERE Sub_ID='$data' LIMIT $start, $limit";
    $result = mysql_query($query1) or die(mysql_error());

    // Initial page num setup
    if ($page == 0){$page = 1;}
    $prev = $page - 1;  
    $next = $page + 1;                          
    $lastpage = ceil($total_pages/$limit);      
    $LastPagem1 = $lastpage - 1;                    


    $paginate = '';
    if($lastpage > 1)
    {   




        $paginate .= "<div class='paginate'>";
        // Previous
        if ($page > 1){
            $paginate.= "<a href='$targetpage?page=$prev'>previous</a>";
        }else{
            $paginate.= "<span class='disabled'>previous</span>";   }



        // Pages    
        if ($lastpage < 7 + ($stages * 2))  // Not enough pages to breaking it up
        {   
            for ($counter = 1; $counter <= $lastpage; $counter++)
            {
                if ($counter == $page){
                    $paginate.= "<span class='current'>$counter</span>";
                }else{
                    $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}                    
            }
        }
        elseif($lastpage > 5 + ($stages * 2))   // Enough pages to hide a few?
        {
            // Beginning only hide later pages
            if($page < 1 + ($stages * 2))       
            {
                for ($counter = 1; $counter < 4 + ($stages * 2); $counter++)
                {
                    if ($counter == $page){
                        $paginate.= "<span class='current'>$counter</span>";
                    }else{
                        $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}                    
                }
                $paginate.= "...";
                $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>";
                $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>";       
            }
            // Middle hide some front and some back
            elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2))
            {
                $paginate.= "<a href='$targetpage?page=1'>1</a>";
                $paginate.= "<a href='$targetpage?page=2'>2</a>";
                $paginate.= "...";
                for ($counter = $page - $stages; $counter <= $page + $stages; $counter++)
                {
                    if ($counter == $page){
                        $paginate.= "<span class='current'>$counter</span>";
                    }else{
                        $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}                    
                }
                $paginate.= "...";
                $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>";
                $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>";       
            }
            // End only hide early pages
            else
            {
                $paginate.= "<a href='$targetpage?page=1'>1</a>";
                $paginate.= "<a href='$targetpage?page=2'>2</a>";
                $paginate.= "...";
                for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++)
                {
                    if ($counter == $page){
                        $paginate.= "<span class='current'>$counter</span>";
                    }else{
                        $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}                    
                }
            }
        }

                // Next
        if ($page < $counter - 1){ 
            $paginate.= "<a href='$targetpage?page=$next'>next</a>";
        }else{
            $paginate.= "<span class='disabled'>next</span>";
            }

        $paginate.= "</div>";       


}
 //echo $total_pages.' Results';
 // pagination
 echo $paginate;
?>


    <?php
$data = $_POST['value'];
    while($row=mysql_fetch_array($result)){

    ?>

    <tr>
    <td><?php echo $row['Pre_Name']; ?></td>
    <td><?php echo $row['pdesc']; ?></td>
    <td><?php echo $row['pdatein']; ?></td>
    <td><?php echo "<a href='{$row['Path']}' title='download file' target='_blank' >Download</a><br />"?></td>


    </tr>
    <?php }
 ?>








</body>
</html>
4

2 に答える 2

0

データのタイプが POST メソッドで渡されるという問題があり、GET メソッドで取得しようとするため、最善の解決策は $_REQUEST を使用できるため、POST または GET の両方を取得できます。

// Get page data
$data = $_REQUEST['value'];

また

$.ajax 呼び出しからこの行を削除します

// type: 'post', 

まだ問題がある場合はお知らせください。

よろしく

于 2013-09-21T20:10:01.327 に答える