PHP Login System with Admin Features

Would you like to react to this message? Create an account in a few clicks or log in to continue.
PHP Login System with Admin Features

This forum was created to talk about the PHP Login System with admin features created by jpmaster77 on evolt's website


4 posters

    Next and Previous

    Dorji
    Dorji


    Number of posts : 25
    Registration date : 2009-03-30

    Next and Previous Empty Next and Previous

    Post  Dorji Tue Apr 28, 2009 8:10 pm

    Hay
    I am thinking of Searching members. and i dont want to show all member in one page and i like to put paging nav. but i am struck with next 10 and previous 10 if the no. of member is more. did anyone try that.
    please help!!
    Helios
    Helios


    Number of posts : 9
    Registration date : 2009-04-21

    Next and Previous Empty Re: Next and Previous

    Post  Helios Wed Apr 29, 2009 11:08 am

    you want to create a query with a LIMIT to the results you fetch?
    Dorji
    Dorji


    Number of posts : 25
    Registration date : 2009-03-30

    Next and Previous Empty re

    Post  Dorji Wed Apr 29, 2009 11:45 am

    Yes and to navigate next 10 member....
    Linchpin311
    Linchpin311


    Number of posts : 220
    Age : 38
    Localisation : Long Island
    Registration date : 2007-05-14

    Next and Previous Empty Re: Next and Previous

    Post  Linchpin311 Wed Apr 29, 2009 5:16 pm

    im pretty sure you would have to query the database twice for this one. Once to find out how many rows are in the database. if you count the number of rows you have, with some math you can find out how many pages you are going to need.

    then the second query will be for the rows you want to display on any given page. in your query, you can use LIMIT to tell mysql where to start fetching rows and how many rows to fetch. And for your next and previous links use GET so you can put what row you should to start from in the URL. put that value in a variable and feed it to your query's limit.
    Dorji
    Dorji


    Number of posts : 25
    Registration date : 2009-03-30

    Next and Previous Empty RE

    Post  Dorji Wed Apr 29, 2009 7:54 pm

    Thank you if problem crops up will post here


    thank u once again...
    Dorji
    Dorji


    Number of posts : 25
    Registration date : 2009-03-30

    Next and Previous Empty Re

    Post  Dorji Thu Apr 30, 2009 9:21 pm

    I tried as you told me using two sql queries
    1. to get num of rows.
    2. for getting data with limit in it.
    now first 10 date are showing but when i click on next the same result is being shown.

    please help
    my email id is drukpakinlay_at_hotmail_dot_com
    Linchpin311
    Linchpin311


    Number of posts : 220
    Age : 38
    Localisation : Long Island
    Registration date : 2007-05-14

    Next and Previous Empty Re: Next and Previous

    Post  Linchpin311 Thu Apr 30, 2009 10:53 pm

    my last post, i feel was rushed so i will try and explain it a little more clearly.

    like i said before you will probably need to execute two separate queries; one to tell you how many pages you will need and another to display however many rows per page (for this example, we'll say 10 rows per page).

    lets say you have 28 rows to display... at 10 rows a page you will need 3 pages to display all of them. if this is the first page, your URL to get here should look like www.example.com/?starting_row=0 and your "Next" link should look something like www.example.com/?starting_row=10. if you say $starting_row = $_GET['starting_row'] you can put the starting row in a variable.

    then your query should probably look something like this
    Code:
    $q = SELECT * FROM `example_table` LIMIT $starting_row,10;
    this will return all rows from table "example_table" starting at whatever the variable $starting_row is set to and it will only return 10 at a time. understand?

    on the second page your url should look like www.example.com/?starting_row=10 cause thats what the "Next" link on the previous page looked like. on the second page, the "Next" link should be www.example.com/?starting_row=20 (to get us to the third page) and the "Previous" link will be www.example.com/?starting_row=0 (to get us to the first page). when you use GET to fetch the starting row before you execute the second query you can dynamically alter the query depending on which page you should be on... or really which rows you want to display!
    Dorji
    Dorji


    Number of posts : 25
    Registration date : 2009-03-30

    Next and Previous Empty RE

    Post  Dorji Fri May 01, 2009 12:32 am

    Thank you sir
    I am unaware of $_GET[''] now my code works fine
    Credit goes to Linchpin311.

    Thanks
    julian
    julian


    Number of posts : 4
    Age : 36
    Localisation : Down Under
    Registration date : 2009-08-20

    Next and Previous Empty Re: Next and Previous

    Post  julian Tue Aug 25, 2009 1:48 am

    Should I have to following data..

    ID Fruits
    -- --------

    1. Watermelon
    2. Pear
    3. Manggo
    4. Apple
    5. Banana
    6. Orange
    7. Apricot
    8. Guava
    9. Blueberry
    10. Pinapple
    ...
    ...
    20. Jackfruits

    .. and I've done added the Next and Previous links, following Linchpin311's post #7, and it works fine Smile
    but, what if it comes to the last data/row? I couldn't figure it out..

    ..or perhaps if I sorted the above data by "Fruits", as the following..


    ID Fruits
    -- --------

    4. Apple
    7. Apricot
    5. Banana
    9. Blueberry
    8. Guava
    20. Jackruits
    3. Manggo
    6. Orange
    2. Pear
    10. Pinapple
    ...
    ...
    1. Watermelon


    ..how to write the script, to tell that it is the end of the row.. that no data is to be showed after "Watermelon"..
    thus you can't click the Next link (or disabled the Next link accordingly)?

    should I missed the discussion about this, please guide me to the post of that discussion..

    please help..
    thank you..
    Dorji
    Dorji


    Number of posts : 25
    Registration date : 2009-03-30

    Next and Previous Empty Re: Next and Previous

    Post  Dorji Tue Aug 25, 2009 2:45 am

    i think you have to use (if else statement).

    1. if there is 0 data not to show (next and previous).
    2. if page is 1 then not to show previous link
    3. if it is the last row then not to show next link.
    4. else show both.

    i hope this is the right one...
    Linchpin311
    Linchpin311


    Number of posts : 220
    Age : 38
    Localisation : Long Island
    Registration date : 2007-05-14

    Next and Previous Empty Re: Next and Previous

    Post  Linchpin311 Wed Aug 26, 2009 12:55 am

    if i am understanding your question right, you might also be able to sort the information with the database query. if you sort fruits it should still return 10 per page, just starting with, in this case, the fourth row or apple.

    Sponsored content


    Next and Previous Empty Re: Next and Previous

    Post  Sponsored content


      Current date/time is Fri May 17, 2024 7:00 am