in my project, a table called 'hardware' contains merely 5000 records..its a mysql database.. the user can add, modify or can view this hardware details one by one.. while clicking 'view' button, the user is redirected to 'hardware_view.php' page and can view the hardware..
my question is.. while the hardware_view.php is loaded, it has to retrieve the first record from the db and has to display the values.. this page contains previous, next buttons.. while clicking next button, it has to display the next record and for previous button also the same... how to do this?.(while the page is loading itself, the records has to be displayed.. and according the next,previous buttons it has to move to corresponding records...)
13 4830
At the present when user clicks views button 'hardware_view.php' must have the current ID/particular ID regarding to the item from the Db to display its details .give the link to the previous button saying (current ID-1) and next button (current ID+1) .This must help u with ur query .
i dont have any ID.. because, if i delete any record from table, for example say 500, tat ID wont exist in the table.... so in table records like, 1,2..,499 then 501...etc will be available.. so i cant just increment or decrement to view the record.. so i dint have tat field..
@sweetline priya
oh ok!!! u can always say in your mysql query at the end that limit 3 order by ID i guess....so that u get 3 available ID's and update the previous and next button.Try this ..
ok sure... thank u for ur immediate reply..
Atli 5,058
Expert 4TB
For this particular purpose, you would want to use the LIMIT clause, pradeepjain is right.
You would simply pass the position of the item you want displayed as a GET or SESSION value, and them fetch it by adding "LIMIT #position, 1" to your SQL query.
But you should always try to include an ID clause in your tables, as a "row counter" of sorts. A field which uniquely identifies each row, even if there are gaps in the count.
If may be (and probably will be) useful later on.
i ve used 'mysql_data_seek' function to retrieve the record from table... this is too functioning properly..
i ve another problem.. ie, i am dynamically creating a table and textboxes to display the values of each record..
during the page_load, first record should be displayed.. for that i ve written a code that should be executed only when the page is loaded for the first time(not executed during the button click)... during the page_load, i am checking if($n==0), if this condition is satisfied, this code is executed.. after displaying the values during the first page_load, i make the value $n=1, thus, the code within the condition($n==0) will not be executed again...
and i ve seperately written code(ie dynamic creation of tables) for 'next', 'prev' buttons.. this code within each post value of these buttons are executed accordingly.. my doubt is whether this is a proper way, is this a good coding... can anybody suggest and guide me???
For your checking if code is executed you could look into the include_once() function ( http://au2.php.net/include_once ) or start storing $n as a session variable: $_SESSION['n'] so you can change it and it is available for that session.
For your next/prev buttons, you can either do something with the $_SESSION or use a $_GET variable. Usually for pagination you use GET variables.
Here is a good pagination link: http://www.tonymarston.net/php-mysql/pagination.html
I hope this helps.
thank you for ur suggestions :)
No problem. Let us know how you go.
@TheServant..
u suggested to prefer 'pagination'.. but i want one record in a page.. so should i limit the num_of_records per page as 1 ???
@sweetline priya
hey ur concept is similar to pagination as the page in which ur in will be static giving link to next and behind page.
ok.. i ll try with pagination
@sweetline priya
Give it a go, and post back with your code so that we can make sure it's the best way to do it. Also obviously let us know if you get stuck with the pagination code too ;)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Wm |
last post by:
I'm trying to get a handle on the best way to handle setting up my listings
so that I display groups of about 25 records per page. I currently have a
page that returns over 1,000 names/addresses,...
|
by: george |
last post by:
Can anyone help?
I query a database and return a result on the column "reference".
There might be 7 listings. Each row is displayed in a table, with
links through to a detail page. I am working...
|
by: Bob Bedford |
last post by:
Does exist a next prev function in PHP/Mysql. I've a website with returns
lot of records (say about 200). The user may browse trough the list or
returned records, but he has to click the record...
|
by: Leroy |
last post by:
I really need some help with showing pages of results from queries in
say like groups of 20 with next and previous buttons or links. I'm
having a lot of trouble figuring out the logic of such a...
|
by: eeh |
last post by:
Hi,
Suppose I have a table "product" with fields id,name,price. I want to
get a resultset of previous and current and next record when the
resultset is sorted by id and id=10. The table data is...
|
by: Karl Roes |
last post by:
Hi All,
I would like some advice on Next / Previous record buttons.
I have a main form for the client, and a continuous subform listing
client transactions. If I open one of these transactions...
|
by: allyn44 |
last post by:
Hello,
I have a table that has null fields that need to be filled in with the value of the previous record
(example below)
id date
1 2/2/02
2
3 4/4/02
4
|
by: David C |
last post by:
I am gathering some ideas.
Just like after you open up an email, on the screen are the previous and
next buttons. You can navigation to the next or previous record.
So how would you maintain...
|
by: Dixie |
last post by:
I have asked this question before, but I could not get the suggested
solution work. So I will give more details this time.
I have an append query that adds several hundred records to a table...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| | |