Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6108149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:15:55+00:00 2026-05-23T14:15:55+00:00

I have created one field unique in my database. Consider the album name is

  • 0

I have created one field unique in my database. Consider the album name is unique. I have successfully added constraints that if user try to add other album with that name he will get error message that record already present. So user may not add any other record with the same name.

But now I have problem that if their are 3 records exists in database with name a,b,c. and user is updating any of field than he can update record b as name of a so their would be two records in database with a. & I want to create it unique. For that I am using script..

if($name!="") {
  $sql = "select a_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
}

But I have problem that with each pageload for updation I need to choose different name for album. because it will show album exist msg. Sometimes it might be possible that I want to change rest of information other than name of album like its year of release, total track. but with this script If I want to update rst of field I need to change album name first. Please help with this problem. So that album name may not repeat in DB and I can update other information also other than name.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:15:56+00:00Added an answer on May 23, 2026 at 2:15 pm

    You could save the oldname in a variable and when updating first check for

    if($name!=$oldname) { ... 

    .
    this way you won’t update the name unless it changed and the updates for the other fields will be made

    $oldname = THE NAME OF THE ALBUM BEING EDITED
    ....
    if($name!=$oldname) {
     if($name!="") {
     $sql = "select a_name from t_a_list where a_name = '$name'";
     $result = mysql_query($sql);
     if(mysql_num_rows($result) != 0) {
         $msg = "Record Not Saved. Album already Exist!";
     }
     } else {
     $msg = "Enter Name of Album!";
     }
     if($msg=="") {
     //Update Query
     }
    }
    if($description!="") {
    ....
    }
    if($location!="") {
    ...
    }
    ...
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created one user named tuser with create database rights in SQL server
i have created one android application that was connecting to sqlite database. and i
I have created one preference page where there are stringfieldeditor. Whenever user give some
I have created one aspx Page from that i need to access the property
I have created one application in flex that is accessing the Java webservice using
I have a database table with a unique string field and a couple of
I have created one listview, in this each row contain check box and the
I have created one table using the below command: create table Table1( Id int
I have created one jsp form which contains the username textfield. On the click
I have created one dynamic button in my application and I call the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.