如何使用ajax和php在mysql表中移动到下一行和前一行


How to move in a mysql table with ajax and php to the next and previous rows?

经过昨天我这边糟糕的沟通和不清楚的问题,我准备了一些东西。我是第一次参加这样的论坛。这很艰难,但很好!我意识到这个论坛里的人是多么的专业。我知道没有一个论坛能接近你的信息质量!

我不是一个甜言蜜语的人,这是事实!问题是:

我连接到一个mysql表,但我不能转到下一行、下一行和下一行,以前的记录也是如此。我还是不太明白。这个代码出了什么问题?我真的很想知道它。

当我点击上一个来"未定义的对象。"

当我跳过下一个时,只出现一个记录,然后它就冻结了。我想我在桌子的尽头。

我在这里读了很多帖子,至少有50篇,但我没有得到。我只是不明白。

来自曼谷的问候

+++

我不使用jquery命令。我只使用json解析来获取数据,但我得到的不多;)

这是非常基本的。我想做的就是获取上一行和下一行。总是只有一行。+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

function jsRecordNext()
{
    // ... the AJAX request is successful
    var updatePage = function( response ) {
    json_string = JSON.stringify(response);
    jsBlankArticle();
    jsShowArticle();
    };
    // ... the AJAX request fail
    var printError = function( req, status, err ) {
    alert("no luck");
    };
    // Create an object to describe the AJAX request
    var ajaxOptions = {
    url: 'nextarticle.php',
    dataType: 'json',
    success: updatePage,
    error: printError
    };
// Initiate the request!
$.ajax(ajaxOptions);
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//previous row
<?php include "accesscontrol.php" ;?>
<?php
$result = mysql_query("SELECT * FROM articles WHERE id<$current_id ORDER BY id DESC LIMIT 1");
$current_id = mysql_insert_id();
$result = mysql_fetch_row($result);
echo json_encode($result);
?>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//next row
<?php include "accesscontrol+.php" ;?> // connection
<?php
$result = mysql_query("SELECT * FROM articles WHERE id>$current_id ORDER BY id ASC LIMIT 1");
$current_id = mysql_insert_id();
$result = mysql_fetch_row($resulat);
echo json_encode($result);
?>
++++++++++++++++++++++++++++++++
this is index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<META HTTP-Equiv="FileTransfer" Content="TransferEvent:url('Javascript:alert('%s')'); Transfer">
<head>
    <meta charset="UTF-8" />
    <title>SoB - Administration</title>
    <link rel="stylesheet" href="../wp-content/themes/Kuraya-Theme/style.css" tppabs="http://www.spiritofbushido.com/wp-content/themes/Kuraya-Theme/style.css">
    <link rel="pingback" href="http://www.spiritofbushido.com/xmlrpc.php">
    <script type="text/javascript" src="../wp-content/themes/Kuraya-Theme/js/scroll.js" tppabs="www.spiritofbushido.com/wp-content/themes/Kuraya-Theme/js/scroll.js"></script>
    <script type="text/javascript" src="../includes/jquery.js"></script>
    <script type="text/javascript" src="userinfo.0.0.1.min.js"></script>
    <link rel="alternate" type="application/rss+xml" title="Kuraya &raquo; Feed" href="http://www.scoobeedo.com/feed/" />
<link rel="alternate" type="application/rss+xml" title="Kuraya &raquo; Comments Feed" href="http://www.scoobeedo.com/comments/feed/" />
<link rel="alternate" type="application/rss+xml" title="Kuraya &raquo; Join Our E-mail List Comments Feed" href="http://www.scoobeedo.com/email-signup/feed/" />
<link rel='stylesheet' id='shadowbox-css-css'  href="../wp-content/uploads/shadowbox-js/src/shadowbox.css-ver=3.0.3.css" tppabs="http://www.scoobeedo.com/wp-content/uploads/shadowbox-js/src/shadowbox.css?ver=3.0.3" type='text/css' media='screen' />
<link rel='stylesheet' id='shadowbox-extras-css'  href="../wp-content/plugins/shadowbox-js/css/extras.css-ver=3.0.3.10.css" tppabs="http://www.scoobeedo.com/wp-content/plugins/shadowbox-js/css/extras.css?ver=3.0.3.10" type='text/css' media='screen' />
<link rel='stylesheet' id='contact-form-7-css'  href="../wp-content/plugins/contact-form-7/styles.css-ver=3.1.2.css" tppabs="http://www.scoobeedo.com/wp-content/plugins/contact-form-7/styles.css?ver=3.1.2" type='text/css' media='all' />
<script type='text/javascript' src="../../ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js-ver=3.3.2.js" tppabs="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js?ver=3.3.2"></script>
<script type='text/javascript' src="../wp-includes/js/comment-reply.js-ver=20090102.js" tppabs="http://www.scoobeedo.com/wp-includes/js/comment-reply.js?ver=20090102"></script>
<link rel='prev' title='東方古玩 蔵屋' href='http://www.scoobeedo.com/%e4%b8%ad%e6%96%87%e7%89%88/' />
<link rel='next' title='Sale 20% &#8211; 40% Off Entire Inventory Before Our Newshipment Arrived. Sales End April 30th.' href='http://www.scoobeedo.com/12131-2/' />
<link rel='canonical' href='http://www.scoobeedo.com/email-signup/' />
    <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>
    <script id="source" language="javascript" type="text/javascript">
        <!--
        var js_string;
        document.getElementById("recordWrite").disabled = true;
        function jsRecordPrevious()
            {
                // ... the AJAX request is successful
                var updatePage = function( response ) {
                    json_string = JSON.stringify(response);
                    jsBlankArticle();
                    jsShowArticle();
                };
                // ... the AJAX request fail
                var printError = function( req, status, err ) {
                    $( '#recordnumber').html( '-' );
                    alert("f p");
                };
                // Create an object to describe the AJAX request
                var ajaxOptions = {
                    url: 'previousarticle.php',
                    dataType: 'json',
                    success: updatePage,
                    error: printError
                };
                // Initiate the request!
                    $.ajax(ajaxOptions);
            }
        function jsRecordCurrent()
        {
            // ... the AJAX request is successful
            var updatePage = function( response ) {
                json_string = JSON.stringify(response);
                jsBlankArticle();
                jsShowArticle();
            };
            // ... the AJAX request fail
            var printError = function( req, status, err ) {
                alert("f c");
            };
            // Create an object to describe the AJAX request
            var ajaxOptions = {
                url: 'currentarticle.php',
                dataType: 'json',
                success: updatePage,
                error: printError
            };
            // Initiate the request!
            $.ajax(ajaxOptions);
        }

        function jsRecordNext()
        {
            // ... the AJAX request is successful
            var updatePage = function( response ) {
                json_string = JSON.stringify(response);
                jsBlankArticle();
                jsShowArticle();
            };
            // ... the AJAX request fail
            var printError = function( req, status, err ) {
                alert("f n");
            };
            // Create an object to describe the AJAX request
            var ajaxOptions = {
                url: 'nextarticle.php',
                dataType: 'json',
                success: updatePage,
                error: printError
            };
            // Initiate the request!
                $.ajax(ajaxOptions);
        }
        function jsShowArticle()
        {
            js_articles = JSON.parse(json_string);
            document.form_articles.newItem.value=js_articles[1];
            document.form_articles.newItemNo.value=js_articles[2];
            document.form_articles.newMaterial.value=js_articles[3];
            document.form_articles.newAge.value=js_articles[4];
            document.form_articles.newItemSize.value=js_articles[5];
            document.form_articles.newPrice.value=js_articles[6];
            document.form_articles.newInfo.value=js_articles[7];
            document.form_articles.newInfoRed.value=js_articles[8];
            document.form_articles.newArrivalDate.value=js_articles[9];
            if (js_articles[10]="Y")
            {
                document.form_articles.newArrivalDateShown.checked=true;
            }
            else
            {
                document.form_articles.newArrivalDateAhown.checked=false;
            }
            document.form_articles.newMainPicLink.value=js_articles[11];
            document.form_articles.newItemCondition.value=js_articles[12];
        }
        function jsBlankArticle()
        {
            document.form_articles.newItem.value="";
            document.form_articles.newItemNo.value="";
            document.form_articles.newMaterial.value="";
            document.form_articles.newAge.value="";
            document.form_articles.newItemSize.value="";
            document.form_articles.newPrice.value="";
            document.form_articles.newInfo.value="";
            document.form_articles.newInfoRed.value="";
            document.form_articles.newArrivalDate.value="";
            document.form_articles.newArrivalDateShown.checked=false;
            document.form_articles.newMainPicLink.value="";
            document.form_articles.newItemCondition.value="";
        }
        function jsNewArticle()
        {
        jsBlankArticle();
        document.getElementById('formheadline').innerHTML='Article Database - Insert New Item';
        document.getElementById('newItem').focus();
        document.getElementById("recordWrite").disabled = false;
        }

        function jsWriteArticle()
        {
        document.getElementById('formheadline').innerHTML='Article Database - I save the new item';

        document.getElementById("recordWrite").disabled = true;
        }

        function jsResetForm()
        {
        jsBlankArticle();
        document.getElementById('formheadline').innerHTML='Article Database';
        document.getElementById("recordWrite").disabled = true;
        jsRecordCurrent()
        }
        jsResetForm();

        // -->
    </SCRIPT>

</head>
<body class="page page-id-11505 page-template-default" onload="jsRecordCurrent()">
    <div id="page-wrap">s
        <?php
        include('../includes/header.html');
        ?>


        <div id="container-main">
        <div id="main-content">


        <div class="post" id="post-11505">
            <h2 class="title-page">SoB - Administration</h2>
            <title>SoB - Administration</title>
            <div id="recordnumber"></div>
            <div class="entry">
                <form method="post" action="<?=$_SERVER['PHP_SELF']?>" name="form_articles">
                    <table border="0" cellpadding="0" cellspacing="5">
                        <tr>
                            <td align="right">
                            </td>
                            <td align="left">
                                <span id="formheadline"><h2>Article Database</h2></span>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                            </td>
                            <td align="left">
                                <span style="padding-right:20px"><font color="orangered" size="+1"><tt><b>*</b></tt></font>indicates a required field</span>
                            </td>
                        </tr>
                        <br>
                        <tr>
                            <td align="right">
                                <span style="padding-right:20px">Item</span>
                            </td>
                            <td>
                                <input id="newItem" name="newItem" type="text" maxlength="100" size="25"/>
                                <font color="orangered" size="+1"><tt><b>*</b></tt></font>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <span style="padding-right:20px">Item No.</span>
                            </td>
                            <td>
                                <input name="newItemNo" type="text" maxlength="100" size="25" />
                                <font color="orangered" size="+1"><tt><b>*</b></tt></font>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <span style="padding-right:20px">Arrival Date</span>
                            </td>
                            <td>
                                <input name="newArrivalDate" type="date" />
                                <font color="orangered" size="+1"><tt><b>*</b></tt></font>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <span style="padding-right:20px">Show in New Arrivals</span>
                            </td>
                            <td>
                                <input name="newArrivalDateShown" type="checkbox" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <span style="padding-right:20px">Material</span>
                            </td>
                            <td>
                                <input name="newMaterial" type="text" maxlength="100" size="25" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <span style="padding-right:20px">Condition of item</span>
                            </td>
                            <td>
                                <input id="newItemCondition"  name="newItemCondition" type="text" maxlength="100" size="25" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <span style="padding-right:20px">Age</span>
                            </td>
                            <td>
                                <input name="newAge" type="text" maxlength="100" size="25" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <span style="padding-right:20px">Item Size</span>
                            </td>
                            <td>
                                <input name="newItemSize" type="text" maxlength="100" size="25" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <span style="padding-right:20px">Price</span>
                            </td>
                            <td>
                                <input name="newPrice" type="text" maxlength="100" size="25" />
                                <font color="orangered" size="+1"><tt><b>*</b></tt></font>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <span style="padding-right:20px">Info Red</span>
                            </td>
                            <td>
                                <input name="newInfoRed" type="text" maxlength="100" size="25" />
                            </td>
                        </tr>
                        <tr valign="top">
                            <td align="right">
                                <span style="padding-right:20px">Infos</span>
                            </td>
                            &nbsp;&nbsp;
                            <td>
                                <textarea wrap="soft" name="newInfo" rows="5" cols="30"></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <span style="padding-right:20px">PicLink</span>
                            </td>
                            <td>
                                <input id="newMainPicLink" name="newMainPicLink" type="text" maxlength="100" size="50" />
                            </td>
                        </tr>
                        <br><br>
                        <tr>
                            <td align="right" colspan="2">
                                <hr noshade="noshade" />
                                <input type="button" name="recordPrevious" value=" < " onclick="jsRecordPrevious()"/>
                                <input type="button" name="recordNext" value=" > " onclick="jsRecordNext()"/>
                                <input type="button" name="recordNew" value=" New "  onclick="jsBlankArticle()"/>
                                <input type="button" name="recordEdit" value=" Edit " onclick="jsShowArticle()"/>
                                <span style="padding-right:20px"></span>
                                <input type="reset" value="Reset Form" />
                                <input id="recordWrite" type="button" name="recordWrite" value=" Write " onclick="jsWriteArticle()"/>
                            </td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>


</div>
            <?php
            include('../includes/sidemenu.html');
            ?>
            <br class="clearfloat" />
     </div> <!-- End of main container -->
</div><!-- END Page Wrap -->
    <?php
    include('../includes/footer.html');
    ?>
</body>
</html>

你好,你缺乏很多Logocal和编程技能,请提高它。

Files()如下所示->

您的index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<META HTTP-Equiv="FileTransfer" Content="TransferEvent:url('Javascript:alert('%s')'); Transfer">
<head>
    <meta charset="UTF-8"/>
    <title>SoB - Administration</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <style type="text/css">.recentcomments a {
            display: inline !important;
            padding: 0 !important;
            margin: 0 !important;
        }</style>
    <script id="source" language="javascript" type="text/javascript">
        var js_string;
        document.getElementById("recordWrite").disabled = true;
        function jsRecordPrevious() {
            // ... the AJAX request is successful
            var updatePage = function (response) {
                json_string = JSON.stringify(response);
                jsBlankArticle();
                jsShowArticle();
            };
            // ... the AJAX request fail
            var printError = function (req, status, err) {
                $('#recordnumber').html('-');
                alert("f p");
            };
            // Create an object to describe the AJAX request
            var ajaxOptions = {
                url: 'previousarticle.php',
                data : {  currentRecord: $("[name='recordPrevious']").attr("id")},
                dataType: 'json',
                success: updatePage,
                error: printError
            };
            // Initiate the request!
            $.ajax(ajaxOptions);
        }
        function jsRecordCurrent() {
            // ... the AJAX request is successful
            var updatePage = function (response) {
                json_string = JSON.stringify(response);
                jsBlankArticle();
                jsShowArticle();
            };
            // ... the AJAX request fail
            var printError = function (req, status, err) {
                alert("f c");
            };
            // Create an object to describe the AJAX request
            var ajaxOptions = {
                url: 'currentarticle.php',
                dataType: 'json',
                success: updatePage,
                error: printError
            };
            // Initiate the request!
            $.ajax(ajaxOptions);
        }
        function jsRecordNext() {
            // ... the AJAX request is successful
            var updatePage = function (response) {
                json_string = JSON.stringify(response);
                jsBlankArticle();
                jsShowArticle();
            };
            // ... the AJAX request fail
            var printError = function (req, status, err) {
                alert("f n");
            };
            // Create an object to describe the AJAX request
            var ajaxOptions = {
                url: 'nextarticle.php',
                data : {  currentRecord: $("[name='recordNext']").attr("id")},
                dataType: 'json',
                success: updatePage,
                error: printError
            };
            // Initiate the request!
            $.ajax(ajaxOptions);
        }
        function jsShowArticle() {
            js_articles = JSON.parse(json_string);
            //Dude , I added it (Pratik)->
            $('[name="recordNext"]').attr("id",js_articles[0]);
            $('[name="recordPrevious"]').attr("id",js_articles[0]);
            document.form_articles.newItem.value = js_articles[1];
            document.form_articles.newItemNo.value = js_articles[2];
            document.form_articles.newMaterial.value = js_articles[3];
            document.form_articles.newAge.value = js_articles[4];
            document.form_articles.newItemSize.value = js_articles[5];
            document.form_articles.newPrice.value = js_articles[6];
            document.form_articles.newInfo.value = js_articles[7];
            document.form_articles.newInfoRed.value = js_articles[8];
            document.form_articles.newArrivalDate.value = js_articles[9];
            if (js_articles[10] = "Y") {
                document.form_articles.newArrivalDateShown.checked = true;
            }
            else {
                document.form_articles.newArrivalDateAhown.checked = false;
            }
            document.form_articles.newMainPicLink.value = js_articles[11];
            document.form_articles.newItemCondition.value = js_articles[12];
        }
        function jsBlankArticle() {
            document.form_articles.newItem.value = "";
            document.form_articles.newItemNo.value = "";
            document.form_articles.newMaterial.value = "";
            document.form_articles.newAge.value = "";
            document.form_articles.newItemSize.value = "";
            document.form_articles.newPrice.value = "";
            document.form_articles.newInfo.value = "";
            document.form_articles.newInfoRed.value = "";
            document.form_articles.newArrivalDate.value = "";
            document.form_articles.newArrivalDateShown.checked = false;
            document.form_articles.newMainPicLink.value = "";
            document.form_articles.newItemCondition.value = "";
        }
        function jsNewArticle() {
            jsBlankArticle();
            document.getElementById('formheadline').innerHTML = 'Article Database - Insert New Item';
            document.getElementById('newItem').focus();
            document.getElementById("recordWrite").disabled = false;
        }

        function jsWriteArticle() {
            document.getElementById('formheadline').innerHTML = 'Article Database - I save the new item';

            document.getElementById("recordWrite").disabled = true;
        }
        function jsResetForm() {
            jsBlankArticle();
            document.getElementById('formheadline').innerHTML = 'Article Database';
            document.getElementById("recordWrite").disabled = true;
            jsRecordCurrent()
        }
        jsResetForm();
    </script>
</head>
<body class="page page-id-11505 page-template-default" onload="jsRecordCurrent()">
<div id="page-wrap">
    <div id="container-main">
        <div id="main-content">
            <div class="post" id="post-11505">
                <h2 class="title-page">SoB - Administration</h2>
                <title>SoB - Administration</title>
                <div id="recordnumber"></div>
                <div class="entry">
                    <form method="post" action="<?= $_SERVER['PHP_SELF'] ?>" name="form_articles">
                        <table border="0" cellpadding="0" cellspacing="5">
                            <tr>
                                <td align="right">
                                </td>
                                <td align="left">
                                    <span id="formheadline"><h2>Article Database</h2></span>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                </td>
                                <td align="left">
                                    <span style="padding-right:20px"><font color="orangered" size="+1"><tt><b>*</b></tt></font>indicates a required field</span>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <span style="padding-right:20px">Item</span>
                                </td>
                                <td>
                                    <input id="newItem" name="newItem" type="text" maxlength="100" size="25"/>
                                    <font color="orangered" size="+1"><tt><b>*</b></tt></font>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <span style="padding-right:20px">Item No.</span>
                                </td>
                                <td>
                                    <input name="newItemNo" type="text" maxlength="100" size="25"/>
                                    <font color="orangered" size="+1"><tt><b>*</b></tt></font>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <span style="padding-right:20px">Arrival Date</span>
                                </td>
                                <td>
                                    <input name="newArrivalDate" type="date"/>
                                    <font color="orangered" size="+1"><tt><b>*</b></tt></font>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <span style="padding-right:20px">Show in New Arrivals</span>
                                </td>
                                <td>
                                    <input name="newArrivalDateShown" type="checkbox"/>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <span style="padding-right:20px">Material</span>
                                </td>
                                <td>
                                    <input name="newMaterial" type="text" maxlength="100" size="25"/>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <span style="padding-right:20px">Condition of item</span>
                                </td>
                                <td>
                                    <input id="newItemCondition" name="newItemCondition" type="text" maxlength="100"
                                           size="25"/>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <span style="padding-right:20px">Age</span>
                                </td>
                                <td>
                                    <input name="newAge" type="text" maxlength="100" size="25"/>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <span style="padding-right:20px">Item Size</span>
                                </td>
                                <td>
                                    <input name="newItemSize" type="text" maxlength="100" size="25"/>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <span style="padding-right:20px">Price</span>
                                </td>
                                <td>
                                    <input name="newPrice" type="text" maxlength="100" size="25"/>
                                    <font color="orangered" size="+1"><tt><b>*</b></tt></font>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <span style="padding-right:20px">Info Red</span>
                                </td>
                                <td>
                                    <input name="newInfoRed" type="text" maxlength="100" size="25"/>
                                </td>
                            </tr>
                            <tr valign="top">
                                <td align="right">
                                    <span style="padding-right:20px">Infos</span>
                                </td>
                                &nbsp;&nbsp;
                                <td>
                                    <textarea wrap="soft" name="newInfo" rows="5" cols="30"></textarea>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <span style="padding-right:20px">PicLink</span>
                                </td>
                                <td>
                                    <input id="newMainPicLink" name="newMainPicLink" type="text" maxlength="100"
                                           size="50"/>
                                </td>
                            </tr>
                            <br><br>
                            <tr>
                                <td align="right" colspan="2">
                                    <hr noshade="noshade"/>
                                    <input type="button" name="recordPrevious" value=" < "
                                           onclick="jsRecordPrevious()"/>
                                    <input type="button" name="recordNext" value=" > " onclick="jsRecordNext()"/>
                                    <input type="button" name="recordNew" value=" New " onclick="jsBlankArticle()"/>
                                    <input type="button" name="recordEdit" value=" Edit " onclick="jsShowArticle()"/>
                                    <span style="padding-right:20px"></span>
                                    <input type="reset" value="Reset Form"/>
                                    <input id="recordWrite" type="button" name="recordWrite" value=" Write "
                                           onclick="jsWriteArticle()"/>
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>
            </div>
        </div>
        <br class="clearfloat"/>
    </div>
    <!-- End of main container -->
</div>
<!-- END Page Wrap -->
</body>
</html>

这是currentarticle.php

<?php
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('testDb', $link);
if (!$db_selected) {
    die ('Can''t use foo : ' . mysql_error());
}
$result = mysql_query("SELECT * FROM articles ORDER BY id ASC LIMIT 1");
$result = mysql_fetch_row($result);
echo json_encode($result);
?>

这是previousarticle.php

<?php
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('testDb', $link);
if (!$db_selected) {
    die ('Can''t use foo : ' . mysql_error());
}
$current_id = $_REQUEST['currentRecord'];
$result = mysql_query("SELECT * FROM articles WHERE id < ".$current_id." ORDER BY id ASC LIMIT 1");
$result = mysql_fetch_row($result);
echo json_encode($result);
?>

这是nextarticle.php

<?php
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('testDb', $link);
if (!$db_selected) {
    die ('Can''t use foo : ' . mysql_error());
}
$current_id = $_REQUEST['currentRecord'];
$result = mysql_query("SELECT * FROM articles WHERE id > ".$current_id." ORDER BY id ASC LIMIT 1");
$result = mysql_fetch_row($result);
echo json_encode($result);
?>

我在某种程度上更改了所有文件。因此,请在您的代码中进行相应的修改。并从下一次开始进行正确的编码。

您添加验证,如如果是最后一行,禁用NEXT按钮,如果是第一行,禁用PREV按钮。我解决了你的问题。

谢谢!