Re: updating a database

From: Date: Wed, 14 Jul 2010 14:05:07 +0000
Subject: Re: updating a database
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-306890@lists.php.net to get a copy of this message
On Wed, Jul 14, 2010 at 9:59 AM, David Mehler <dave.mehler@gmail.com> wrote: > Hello, > 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. > Thanks. > Dave. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Are you passing back the id of the record that you want to see as the value for the checkbox? It should be a simple matter then of pulling just that id <?php //check and set the id $id = ''; if(!empty($_POST['id'])){ $id = (int)$_POST['id']; } $sql = "select * from table where 1 "; if(!empty($id)){ $sql = " and record_id = $id "; } //run query here ... ?> -- Bastien Cat, the other other white meat

« previous php.general (#306890) next »