RE: [PHP] updating a database

From: Date: Wed, 14 Jul 2010 14:29:47 +0000
Subject: RE: [PHP] updating a database
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-306891@lists.php.net to get a copy of this message
From: David Mehler > What i'm trying to do certainly doesn't seem hard conceptually, but > coding it has been rough. I'm wondering if anyone has anything > similar. > I've got a database with records. The first time the page is accessed > the submit button won't be selected, so display information about the > record with a checkbox for selection. If a user selects a checkbox and > hits submit, display only that specific record in a form for editing, > once editing is complete feed the edited data back to the database. > I'd like all this to be done in a single sticky file. > If anyone has any code similar to this i'd appreciate getting a look, > mine is nonworking. Mine looks something like this -----8<------------------------------------------- $Submit = $_POST['Submit']; if (isset($CCsubmit)) { //////// DELETE if ($Submit == "Delete") { // Check to see if user authorized, then delete record } //////// NEW else if ($Submit == "New" || $Submit == "Next"){ // Issue empty form or next record } //////// EDIT else if ($Submit == "Save") { // Validate and ssve the updated data. Reissue if validation fails. } } else { // Issue form with initial data } -----8<------------------------------------------- You should also check in the Save option to see if anything was actually changed. The record shouldn't be updated if nothing was edited. Bob McConnell

« previous php.general (#306891) next »