linking a research form with a display page

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hello everybody,

I have a page rech.php where I'm doing a multi-criteria research Ex.
choose your car model, choose your country.
After validation of my form, on the same page, the lines will be
displayed (I put a max limitation of 500 lines). Ex. list of cars Fiat
to buy in UK.

A clic on a line will bring me to the display page disp.php Ex. I will
clic on the car n° 5 => <a href="disp.php?
line=5&country=uk&model=Fiat">car n°5</A>.
As you can see disp.php will receive in parameters all the
informations of my query (country=, model=) and I will re-execute the
big multi-criteria query in disp.php for each page!
But if the webmaster will delete the record n°4, I'm bloqued. I'm in
disp.php on the record n°5 and if I clic on the previous button, the
script will look for the record n°4 which doesn't existe anymore.

Here is my big question : Is there a solution to do only once the big
multi-criteria request and save it in a temporary table (but then when
do I need to delete the temp table) or an other solution to do things
better ?

Thanks for your help


Re: linking a research form with a display page

Quoted text here. Click to load it
so the problem is when/if the webmaster deletes a record between the
time the user initially requests the listing and when he finally
clicks on that record (or previous, in your example)?

Quoted text here. Click to load it

Yes...but first are you sure you want to do this?  If the webmaster,
or whoever, deletes a record in the database, I'm sure there was a
reason for it...the data isn't valid anymore and the user shouldn't
see this ghost data.

Depending on your database, you can create a persistent session,
create a temp table within the database with the data you want to
preserve, and when the session is closed the temp table dies.  Now,
persistent DB sessions have their own set of problems, in addition to
the data "ghosting" I talked about as well as the user getting old
data.  For example, what if the user searches and your webmaster ADDS
data to the database?  That data won't be available until they kill
their session and create another?

A temp table might not be best solution for temporarily saving your
data either, but that's what you asked for.  Depending on your data
size, it might be best for a namespace within the $_SESSION

Still, I highly suggest you consider all the effect this would have on
your application.  Yes, there are some downsides to typical web
application development (in this case, a new request per page
refresh), but that also opens doors to others.


Re: linking a research form with a display page

Quoted text here. Click to load it

Thanks Steve for your long answer.
To better understand, imagine a big dating site where you have each
minutes a new user. If I'm look for the last 500 new users, during my
browsing in the disp.php I will have new users and maybe some other
being invalidated... A lot of changing during my consultation. Of
course, it's not important if I didn't see the new users during my

Quoted text here. Click to load it

I'm presuming temporary table will then be the best solution ?
Is it easy to do ?
I heard .net has a solution to create a sort of automatic table in
cache mode... I'm sure there should be someting easy in php to manage
this king of search->browse in display

Re: linking a research form with a display page

Quoted text here. Click to load it
Quoted text here. Click to load it

I will state that I still don't understand why you would want to show
your users old data, but that might be just because I'm not reading
things correctly. There are reasons for caching data, however, so I'll
address that issue, not your reasoning for doing this. (Although, be
sure that's really what your customers want and, maybe more important,
are expecting).

since you want to cache your data off the main database table(s), you
have a couple choices...each with there own positives and negatives.
Lets focus on the performance aspect, though.  If your pulling data
from a normalized database, possibly with a complex query or set of
queries, you would probably benefit from caching the data in the
database.  This option becomes more attractive if you don't have to
initially process the data and send it back, but rather tell the SQL
server to create the temp table based on your query and from that
point on, use that one.  If the dataset is small, however, you might
want to consider caching the data in files/SQLlite on the server.
Doing this of course eliminates the overhead of calling the database.

Just like if you were looking into a .NET solution, your going to need
some external tools.  In PHP's case (and I only speak for PHP, not
comparison to .NET), these tools are actually 1st party.  Included in
Zend Framework is a neat set of classes for frontend and backend cache
management.  Don't let the name "Framework" make you stand off,
though.  It's not like you have to actually use the framework in a MVC
sense, you can just use the cache classes without any overhead of the
others thanks to the loosely coupled design.  And, if your already
using a MVC Framework like Cake or Symfony, you can easily mash up the
ZF classes.

Take a look at the ZF cache classes.

Also, you'll need to do a little research on your specific database
and the commands necessary to create a temp table.  I've achieved this
on a MSSQL05 server, so I know it can be done.  If you have some
problems finding this information, just let me know your DB or visit
you friendly neighborhood db-specific group. =)

Site Timeline