473,473 Members | 1,800 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

next / previous buttons

194 New Member
hi everybody,

im trying to make next and previous buttons. im displaying record based on a search. when any image on the search results is clicked then dat image opened in a new page with details about dat imgae on a seperate page. lets say this image as a coupon. now im trying to navigate to next and previous records without going back.

Expand|Select|Wrap|Line Numbers
  1. while($resultSet = mysql_fetch_assoc($que)){
  2. $np[] = $rs['item_id'];
  3. }
  4. $_SESSION['np']= $np;
  5.  
  6.  
Doing this way im storing all searched ids in an array. this code is at the search results page. and image details page contains the following code.

Expand|Select|Wrap|Line Numbers
  1. foreach($_SESSION['np'] as $key=>$value){
  2. $nps[] = $value;
  3. }
  4. $nps = implode(",",$nps);
  5. $numresults=mysql_query("select * from discount_items where item_id IN($nps)");
  6.  
  7.  
when an image is clicked at the search results page im redirecting user to image details page and passing id in the url. so i know the current value in the session variable. i have googled around about it but i didnt get any useful solution of it. i tried the following function from php.net:

Expand|Select|Wrap|Line Numbers
  1. function array_key_relative($array, $current_key, $offset = 1) {
  2.         // create key map
  3.         $keys = array_keys($array);
  4.         // find current key
  5.         $current_key_index = array_search($current_key, $keys);
  6.         // return desired offset, if in array, or false if not
  7.         if(isset($keys[$current_key_index + $offset])) {
  8.             return $keys[$current_key_index + $offset];
  9.         }
  10.         return false;
  11.     }
  12.  $next_key = array_key_relative($test_array, $_REQUEST['id'], 1); 
  13.  $prev_key = array_key_relative($test_array, $_REQUEST['id'], -1); 
  14. echo "<a href='image_details?id=$next_key'>Next</a><a href='image_details?id=$prev_key'>Previous</a>"
  15.  
i failed to get the values instead of keys. please tell me how i can get the values. thanx
Apr 14 '10 #1
1 3423
mfaisalwarraich
194 New Member
ok i got the solution myself :)). just by changing array_keys to array_values. it worked.
Apr 14 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Marcel | last post by:
Hello, I'm working on a search application for my website. The website contains a lot of pictures, and a search should return clickable thumbnails. No problems there. My problem started when I...
9
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...
1
by: msnews | last post by:
Hi All, My client has following request. I am not sure how to do it. Dynamically from database, we are getting set of images names. Now we want to display them with next and previous buttons....
1
by: Reb | last post by:
Hi all, I have not successfully found a Javascript sample for getting next and previous links from a file... I figured that someone must have solved this problem already! ... here is what I'm...
5
by: Nick Gilbert | last post by:
Hi, I'm using the asp:Wizard control and on some of the steps, I would only like the user to be able to progess to the next step by clicking an image button. Therefore I would like to be able to...
3
by: karen987 | last post by:
Can someone please explain what code i need to add to keep a set of links at the bottom of a pop up window? I need it in a page where people post comments. It is a pop up window, of about 500x400...
3
by: anejamanish | last post by:
Hi guys I am developing a website using php and ajax. Here I need to to design previous and next buttons to load new html files with every click. I am displaying these files within a div tag....
8
by: GaryDean | last post by:
I have a Wizard page and need to affect the next and previous buttons from my code-behind. I've googled around and found two solutions, and neither appear to work. I can access the SideBarList...
3
by: =?Utf-8?B?a2FyaW0=?= | last post by:
Hello All, if I have this code: PictureBox1.ImageLocation = "c:\file.jpg" would I be able to add a next & prevous bottons to go to the next picture in this folder or the previous one? and if I...
13
by: sweetline priya | last post by:
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.