Re: using php to write a checkbox value into a mysql database

From: Date: Sun, 11 May 2003 01:26:48 +0000
Subject: Re: using php to write a checkbox value into a mysql database
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-147178@lists.php.net to get a copy of this message
Bruce Douglas wrote: > > Hey.... > > A short (and hopefully simple) question!! I'm trying to immeadiately write > the value of a modified checkbox into a mysql table. Does anyoe know of a > good/fast/easy way to accomplish this kind of task. > > Basically, when the user selects a box, or deselects the box, I'd like to be > able to write the result to the mysql table. I'd like to be able to do this > without having to use a submit button. Yes, but... Yes, you *COULD* do that by writing some JavaScript that on each onClick="updateserver(this)" would execute a JS function updateserver which would GET/POST data to the web-server, which would UPDATE the database. *HOWEVER* 1) This would not work on browsers with JavaScript disabled. 2) This would be DOG SLOW! 3) This would chew up HTTP connections, a valuable limited resource It would be a BAD IDEA all around. The browser/server connection is GONE by the time the browser displays the checkbox. To synchronize like this, you'd have to make another HTTP connection (IE, "surf" programmatically in the background ti another page) on EVERY click. It's crucial that you keep in mind the vast gulf between the browser and the server -- The HTTP connection/protocol is a very short-lived beast, and is pretty much just a single one-time "round trip" communcation. There is one other possiblity: Use Java servelet/applet to define an interface and keep the connection open (stay-alive). This would require an awful lot of programming, and as I understand it, would be still kinda slow, and maybe even flaky, depending on the browsers you intend to support, and what versions of Java are on your server, and your programming skill, and... It would be a better answer than using PHP, but not necessarily a good answer, as I understand it... But I'm not a Java programmer, and this isn't a Java list, so I'll shut up now.

« previous php.general (#147178) next »