Jump to content

[SOLVED] UPDATE FOR .field?


l3asturd

Recommended Posts

ok, I'm trying to UPDATE a row based on the username.

 

So, I assume to code looks something like:

 

<?php
$update_result = mysql_query(UPDATE $dbtable SET $dbtable.Score = "Updated Score" FOR ($dbtable.Name =($POST_['Username']));


?>

 

Now I realize this is probably completely way off, but this is how I have interpreted that it should be done.

So, I type in a username, and in theory, it should UPDATE the usernames score to "Updated Score" right? Someone please explain how this is SUPPOSED to be done?

Link to comment
https://forums.phpfreaks.com/topic/62953-solved-update-for-field/
Share on other sites

Almost, the proper syntax for an update query is

 

$query="UPDATE tablename SET fieldname='$newvalue' WHERE fieldname='$fieldnamevar'";
$result=mysql_query($query);

 

 

This is the general syntax. You should use an ID in the where clause so you get the correct record updated with minimal chances of error.

 

Nate

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.