A couple of days back I was working on a mobile optimized website.Since Javascript is not supported in mobile phone browsers (though Opera Mini and some others do but most of the default browsers don't!) I had to figure out a way to display tiny bits of a large result without querying the server every time.I was facing the following problem...A couple of days back I was working on a mobile optimized website.Since Javascript is not supported in mobile phone browsers (though Opera Mini and some others do but most of the default browsers don't!) I had to figure out a way to display tiny bits of a large result without querying the server every time.I was facing the following problem...
I had a huge array that contained search results from a database and I had to display one result at a time without querying the server every time.Well, if I had Javascript I would have put each result in a container and kept all of them invisible except the one that I wanted to display.Since I don't have that option I had to use the following PHP hack.
I queried the server for the results and got an array.After getting the array, I serialized it using serialize() function and passed it along with a display index using GET to a display URL.I unserialized() the string in the display page, thereby recovering the array.Using the display index I could display the desired element.So I could display each element without querying the server each time for results.
This is not an uncommon technique but it will help you if you are stuck without Javascript like me :)
Note:There are other ways of passing information using curl etc, but you will need support from the server for using them.
I had a huge array that contained search results from a database and I had to display one result at a time without querying the server every time.Well, if I had Javascript I would have put each result in a container and kept all of them invisible except the one that I wanted to display.Since I don't have that option I had to use the following PHP hack.
I queried the server for the results and got an array.After getting the array, I serialized it using serialize() function and passed it along with a display index using GET to a display URL.I unserialized() the string in the display page, thereby recovering the array.Using the display index I could display the desired element.So I could display each element without querying the server each time for results.
This is not an uncommon technique but it will help you if you are stuck without Javascript like me :)
Note:There are other ways of passing information using curl etc, but you will need support from the server for using them.
No comments:
Post a Comment
Leave a comment