If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > need simple query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-07-10, 03:23
don_log don_log is offline
Registered User
 
Join Date: Jun 2008
Location: pakistan
Posts: 109
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
Reply With Quote
  #2 (permalink)  
Old 02-07-10, 04:36
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 02-07-10, 10:35
don_log don_log is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 02-07-10, 10:38
don_log don_log is offline
Registered User
 
Join Date: Jun 2008
Location: pakistan
Posts: 109
any one other who make me the query i will be very thanks full to you
Reply With Quote
  #5 (permalink)  
Old 02-07-10, 11:14
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
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?
Reply With Quote
  #6 (permalink)  
Old 02-09-10, 08:04
don_log don_log is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On