pixeltrace Posted July 28, 2007 Share Posted July 28, 2007 hi, i have a edit form for my brand items and one of the items that i may need some validation is the brand name. my problem is, i need a validation code for the brand name wherein if the brandname was changed it will execute this validation to check if there is already an existing brand name but if the brandname was not changed it will not execute this validation code. currently this the validation code that i am using $sql_brand_name_check = mysql_query("SELECT brand_name FROM engsoon_brands WHERE brand_name!='$brand_name' AND bid!='$bid'"); $brand_name_check = mysql_num_rows($sql_brand_name_check); if($brand_name_check > 0){ echo '<script language=javascript> alert("brand name already exist.<br>use a different brand name!");top.location = "brandsmngr.php?id=3&bid='.$bid.'";</script>'; unset($brand_name); exit(); this one no matter i modify the brand name or not, its still prompting me the message. hope you could help me fix this. thanks! Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted July 28, 2007 Share Posted July 28, 2007 Try change the query to SELECT brand_name FROM engsoon_brands WHERE brand_name='$brand_name' OR bid='$bid' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.