Jump to content

Recommended Posts

i have a form that edits a user in the database.  here is what i have right now:

 

if (isset($_POST['submit'])) {
	mysql_select_db($database_uploader, $uploader);    
    	$query = "SELECT * FROM members WHERE id='" . mysql_real_escape_string($id) . "'";
	if (mysql_num_rows($result) > 0) {
		$name = $row[name];
		$username = $row[uname];
		$email = $row[email];
		$acntActivation = $row[activated];
		$accountType = $row[acntType];
		$accountStatus = $row[acntStatus];
		$bandwhitech = $row[bandwhitech];
		$notes = $row[notes];
		$timezone = $row[timezone];

		// METHOD: If $_post[name] != $name, then update database record to new value

		mysql_query(sprintf("UPDATE members SET notes = '%s'", mysql_real_escape_string("hello there!")))
		or die(mysql_error());  
		mysql_close($con);
	}
}

 

1)  the notes are not being updated

2)  what would be the best way to update each field that is changed.  i was just going to insert each individually, after checking if it is different than what is in the database for the record.  would it just be better to update the whole record, instead of one piece at a time?  it seems like the first way would take up too much load time. :P

Link to comment
https://forums.phpfreaks.com/topic/245853-efficent-method-of-updating-database/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.