Is it possible to have a HTML SELECT/OPTION value as NULL using PHP?

后端 未结 5 1234
Happy的楠姐
Happy的楠姐 2020-12-29 19:42

The following is a snippet from my HTML form which pulls the options from the table rows accordingly.

What I want to do is have the first option value to be NULL so

5条回答
  •  别那么骄傲
    2020-12-29 20:12

    No, POST/GET values are never null. The best they can be is an empty string, which you can convert to null/'NULL'.

    if ($_POST['value'] === '') {
        $_POST['value'] = null; // or 'NULL' for SQL
    }
    

提交回复
热议问题