Jump to content

Recommended Posts

Ok so I have a page with a table that is filterable(javascript). After any filter is performed a button appears that asks "Would you like to edit this data?" ..my problem is how can i possibly send the id values to a different page using javascript? I thought I could encrypt the array with an ajax call to avoid javascript/php encryption/decryption problems, and then decrypt it on the edit page to reveal the array, however the encryption gets longer and longer as more results are in the array. Forming a link with the values in the address bar would potentially fail, as the amount of values could grow to be huge. Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/177018-passing-array-to-new-page/
Share on other sites

Can you explain a little more? Are you sending a value to a php script? (i.e like posting a form or going to www.site.com?value=123) etc. Or should you be on a javscript forum?

 

Possible ideas:

 

(1) You can use javascript to store a cookie (stored in the browser). Not sure what limitiations are as to size though.

 

(2) The address bar can hold more characters than you think - again not 100% sure, but about 60,000 odd I think (or may be a limit in bytes).

 

(3) You could POST a value to the server - again may be able to send more characters than you think. (address bar values not seen but can be picked up by someone 'sniffing' network traffic if not using SSL.

 

(4) If you use HTTPS (SSL) then there is no need to worry about encrypting it. Nobody will see it anyway.

Ok so I have a table that I am displaying. Let's assume that the table has 500 rows(it currently has just below that, but for arguments sake lets stick to even round numbers). Now lets say I filter the 500 rows by date, and only 135 remain on the screen. I simply need to pass an ID number of each row to another page for editing. So that way, on the edit page, I could display the correct information for editing. Now, like I said I've considered different options, but nothing that is fool proof. I dont want to have to ever go back and deal with it because there is a limit on GET variables. I'll likely have forgotten that by then.

 

There has to be a way to send the data to the next page without limitations...right?

Crayon Violent: yeah i thought about that also, but there are over 20 columns to filter by, i would literally have to build a query generator based on handling each column output. if its the only way then so be it, but it just adds a lot of overhead if something in the database changes.

If php did the filtering, you could store the details in a $_SESSION before displaying:

 

(1) User input, POST to php

(2) php decides to return 135 of 500 rows

(3) php stores info on these 135 rows

(4) display to user

 

If javascript MUST do the filtering - you are going to struggle. I can't see why you would want this - unless it was something like a way to display an Excel spreadsheet in javascript - or say if you MUST use a flash application for example - can't think why I would ever want to do any of this though.

 

If filtering is done by a php database then this is simple in many different ways.

hmm.. dunno if a session would be a good way to go, if he's got a ton of data.  Alternatively you could go the route of having a temporary file created (based off a session id would be good), with the filtered data.  I would use ajax to update the file as you filter it. then on the next page, simply grab the data from the file and display it.

If php did the filtering, you could store the details in a $_SESSION before displaying:

 

(1) User input, POST to php

(2) php decides to return 135 of 500 rows

(3) php stores info on these 135 rows

(4) display to user

 

If javascript MUST do the filtering - you are going to struggle. I can't see why you would want this - unless it was something like a way to display an Excel spreadsheet in javascript - or say if you MUST use a flash application for example - can't think why I would ever want to do any of this though.

 

If filtering is done by a php database then this is simple in many different ways.

 

the advantages of using javascript are: a) less database hits b) client side sorting and filtering keeps load off server c) you load it once and filter and sort all you want. its actually quite good, and super fast.

 

Crayon Violent: i thought of that too. i just didnt want to have to resort to having to read/write to a file..although it does seem like the only conceivable option. would serializing the array help any with speed, in terms of reading the file?

re: serializing the array

 

Whether using functions to serialize/unserialize it, or manually building the array...I mean it might be technically faster, to do it, but in essence php is doing the same thing either way.  Suppose you could try to run some tests and see which one loads faster, but offhand I don't think there's going to be much of a difference.  Dunno though.  Actually, depending on how complex the structure is, I might actually put my money on manually doing it (with file, explode etc.. whatever..dunno what the structure looks like so can't know for sure)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.