undefined value for empty database record

Brownman Revival

What is the best solution to undefined values being returned by database when the column is empty. Is there another way than having

if (!(databasevalue == 'undefined') || !(databasevalue == null)) {

    console.log(databasevalue)

} else {

    console.log('Value is empty')


}

This is ok if only few values can be empty what if multiple values can be empty DO i check each value if undefined or not then show the result

UPDATE

$.ajax({
    type: 'POST',
    url: 'php',
    dataType: "json",
    data: {
        id: "id"
    },
    success: function (data) {
        //check which data is undefined or not
    },
    error: function (data) {
        console.log(data);
    }


});

Is there are collective checking to see which data from the response is undefined or you need to check each have an if condition to check if the data is empty or not

Satpal

You need to use && operator instead of || and undefined should not be in quotes

if (!(databasevalue == undefined) && !(databasevalue == null)) {
    console.log(databasevalue)
} else {
    console.log('Value is empty');
}

However simplest solution is you should check for truthy condition, Following condition is to check databasevalu has value

if (databasevalu) { //!!databasevalu
    console.log(databasevalue)
} else {
    console.log('Value is empty');
}

!! double-negation is used for conversion of condition to boolean instead of truthy

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

concate the value into table if record is empty

From Dev

Using button_to to create new record in database, error: param is missing or the value is empty

From Dev

Using button_to to create new record in database, error: param is missing or the value is empty

From Dev

Getting record from database that has empty field

From Dev

Update a record value in java database

From Dev

Qt fetched database record field values are empty, the data EXISTS in database

From Dev

Arrayed input value inserts empty record in mysql

From Dev

Arrayed input value inserts empty record in mysql

From Dev

Delete record while inserting value to database

From Dev

Translating a Mysql Database Record Value into a PHP command

From Dev

Codeigniter ignore empty array items on update database record

From Dev

How not to print empty string from database while editing record

From Dev

Custom Validation if textbox is empty but data still to record in database

From Dev

check if input is empty then the default value will be send to the database

From Dev

How to store empty value to database table

From Dev

Database trigger: comparison of column value with empty variable

From Dev

String value accumulating empty spaces in MySQL database

From Dev

PHP MySql: Insert empty upload value to database

From Dev

Spinner from database - add empty value as first

From Dev

String value accumulating empty spaces in MySQL database

From Dev

Variable empty after assigning value from database to it

From Dev

How to not update database if $_POST value is empty?

From Dev

get method returns undefined value although inside the method the value is not empty

From Dev

Can't set empty object as default value for param with type Record

From Dev

Lift Record: empty value for required field but no validation errors

From Dev

How to find a record with an empty field value using VBA in Access?

From Dev

Angular.js ng-switch ---testing if value is empty or undefined

From Dev

Angular select dropdown empty value doesn't reset to undefined, why?

From Dev

Angular select dropdown empty value doesn't reset to undefined, why?

Related Related

  1. 1

    concate the value into table if record is empty

  2. 2

    Using button_to to create new record in database, error: param is missing or the value is empty

  3. 3

    Using button_to to create new record in database, error: param is missing or the value is empty

  4. 4

    Getting record from database that has empty field

  5. 5

    Update a record value in java database

  6. 6

    Qt fetched database record field values are empty, the data EXISTS in database

  7. 7

    Arrayed input value inserts empty record in mysql

  8. 8

    Arrayed input value inserts empty record in mysql

  9. 9

    Delete record while inserting value to database

  10. 10

    Translating a Mysql Database Record Value into a PHP command

  11. 11

    Codeigniter ignore empty array items on update database record

  12. 12

    How not to print empty string from database while editing record

  13. 13

    Custom Validation if textbox is empty but data still to record in database

  14. 14

    check if input is empty then the default value will be send to the database

  15. 15

    How to store empty value to database table

  16. 16

    Database trigger: comparison of column value with empty variable

  17. 17

    String value accumulating empty spaces in MySQL database

  18. 18

    PHP MySql: Insert empty upload value to database

  19. 19

    Spinner from database - add empty value as first

  20. 20

    String value accumulating empty spaces in MySQL database

  21. 21

    Variable empty after assigning value from database to it

  22. 22

    How to not update database if $_POST value is empty?

  23. 23

    get method returns undefined value although inside the method the value is not empty

  24. 24

    Can't set empty object as default value for param with type Record

  25. 25

    Lift Record: empty value for required field but no validation errors

  26. 26

    How to find a record with an empty field value using VBA in Access?

  27. 27

    Angular.js ng-switch ---testing if value is empty or undefined

  28. 28

    Angular select dropdown empty value doesn't reset to undefined, why?

  29. 29

    Angular select dropdown empty value doesn't reset to undefined, why?

HotTag

Archive