Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2008
    Location
    pakistan
    Posts
    109

    Unanswered: need simple query

    i have a table in mysql which have 3 fields id,title,stuff
    i need a query which show record one record per one page just need a query with next and previous button give me the query just i have to copy and paste it and my work done by it so please give me the query or it shows page number or articles number or give me the link of any article manager which doesn't have any ad cause i need it

    my article will show like this if you will give me coding like this

    here is the title
    here is the stuff too


    next record or page 1 to .... previous record

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so you need to know the current record, and he order/criteria you got to that record, for that it should be possible to get the next or previous record.

    depeding on how you retrieve the data it should be fairly trivial.
    assumign you are using PHP in a web (internet or intranet) environment the next / previous buttons should call the same page with the relevant primary key.

    a quick and dirty way of doing this would be to issue two queries which retrieve the next row (use the LIMIT 1 clause. one query should request ASCending sort order for the next, the other should specify the DESC. the problem is going to e making sure you are using the same criteria (and therefore the same sort orders)

    so in this case youd need something like
    //to find next record
    select id,title,stuff from mytable where ID>=blah order by ID ASClimit 2 //retrieves the current speciified ID and the next row
    //to find previous record
    select id,title,stuff from mytable by ID where ID<blah order by ID DESC limit 1 //retrieves the previous row
    you will need to check if each query returned valid data... ie you may be at the beginning or end of the dataset and therefore not have a previous and or next record.

    having retrieved the id of those rows you then call the same form with the desired id.
    you could expand the same methodology to say go back/forward 10 rows.
    the first or last record can be found using something such as

    select Min(id) as MinID,title,stuff from mytable
    select Max(id) as MaxID,title,stuff from mytable
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jun 2008
    Location
    pakistan
    Posts
    109
    if you setuped the query and make query for me so please tell me the whole query so i just paste it and make my query complete cause i don't know much more about php and make website from scratch so please make me the query with every thing setup i don't have to show it id just title and stuff please tell me that

  4. #4
    Join Date
    Jun 2008
    Location
    pakistan
    Posts
    109
    any one other who make me the query i will be very thanks full to you

  5. #5
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    Quote Originally Posted by don_log View Post
    cause i don't know much more about php and make website from scratch so please make me the query with every thing setup
    don_log - if you don't know much about PHP and (I'm guessing) very little about MySQL then just why are you trying to make a website from scratch? Would it not be better to spend your time trying a few web based tutorials to learn these skills first? Or is this coursework?

  6. #6
    Join Date
    Jun 2008
    Location
    pakistan
    Posts
    109
    dear i have tell you i setuped all the thing like header.php , rightside.php
    footer.php just i need a little coding i have to submit a screenshot here just wait a little to explain you more

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •