Doubt using update query
I have particular column unique in my database. So regarding that I am using this particular script with the name
field to avoid duplicacy. But issue is if sometimes I want to update other field except name field than query is not firing. Please give me proper approach with this. using my particular script if I wish to make changes in some row than I need to make changes in name field also...Chk it out.
if($name!="") {
$sql = "select a开发者_JS百科_name from t_a_list where a_name = '$name'";
$result = mysql_query($sql);
if(mysql_num_rows($result) != 0) {
$msg = "<font color=red>Record Not Saved. Album already Exist!</font>";
}
} else {
$msg = "<font color=red>Enter Name of Album!</font>";
}
if($msg=="") {
//Update Query
}
Example.. COnsider example I have name field that includes email ids of the user. Now if user want to update his mail id than this script is successfully executing but if he want to make changes to the other field like his name, contact number, address how does this script need to be modify. If user want to change mail id than it will successfully run and avoid and check for mail id if exist. But not for other field. If he want to make changes to other field than he surely have to change his name field first.
If you want to fire update query when $msg
is sent, you should use ($msg != '')
in if
statement.
The text box name in script
and in html
are different please correct it
精彩评论