#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Navigation through records


    hi, I am generating records through php/sql, as u can see the code displays 5 records, what Im trying to do is program so that when the next button is pressed the next 5 records will show?? any help much appreciated thank you,

    the code -
    Code:
        function show(qstring,qtype){
        $("#vsdiv").show();
        var myurl="scripts/searchpage.php";
        $.ajax({
        url: myurl, dataType:'json',data:{querystring:qstring,querytype:qtype},
        success: function(member){
        $("#results").append('<tr class="me">'+
        '<th>#REC</th><th>name</th><th>surname</th>');
        var j=0;var totrecs=1;
        for(var i=0;i<5;i++){
        $("#results").append('<tr class="rows'+j+'">'+
        '<td class="ids" id="z'+i+'">'+totrecs+'</td>'+
        '<td>'+name[i].bdate+'</td>'+
        '<td class="users" id="username'+i+'">'+member[i].username+'</td>'+
        '<td id="contact'+i+'">'+member[i].fname+' '+member[i].lname+'</td>'+
        '<td><input type="checkbox" name="whome" id="showMe'+i+'"'+
        'class="boxes" onclick="getMe('+i+')" /></td></tr>');
        totrecs++;
        j++;
        }
        }
        });
        }
    and for the html button -
    Code:
        <input type="button" id="next5" title="Next 5 Records" disabled="disabled" value="Next 5>>" />
  2. #2
  3. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,009
    Rep Power
    2791
    Welcome to DevShed, davidp.

    A variable with an increment of 5 per click should do the trick. Where is the event function for the button?

    Leaving work in 5 minutes, so someone else may need to reply.
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0
    Thanks you, I dont yet have the event function for the button, any help with the code for the next button?? dont know how to start it
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    194
    Rep Power
    77
    you could easily do this in php using pagination and then using ajax so it doesn't reload the entire page every time the next or back button is clicked
  8. #5
  9. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,009
    Rep Power
    2791
    The script is already using jQuery's AJAX functions. So, you already have your JSON object you are sending to your server-side script. You just need to add a pagination number to it. Here is a pseudo-example to give you the concept.
    Javascript Code:
    var recordCount = 0;
     
    function show(args) {
     
    	// existing code.
     
    	dataType:'json',data:{querystring:qstring,querytype:qtype,rcount:recordCount}
     
    	// existing code.
     
    	recordCount += 5;
    }
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.

IMN logo majestic logo threadwatch logo seochat tools logo