Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP未在选择框和文本区域的表中显示MySQL中的值_Php_Mysql_Sql Update - Fatal编程技术网

PHP未在选择框和文本区域的表中显示MySQL中的值

PHP未在选择框和文本区域的表中显示MySQL中的值,php,mysql,sql-update,Php,Mysql,Sql Update,Information.php <?php if (empty($_POST)===false){ $required_fields = array('first_name','last_name','gender','age','location','about_me'); foreach($_POST as $key =>$value){ if(empty($value) && in_array($key, $required_f

Information.php

<?php

if (empty($_POST)===false){
    $required_fields = array('first_name','last_name','gender','age','location','about_me');
    foreach($_POST as $key =>$value){
        if(empty($value) && in_array($key, $required_fields) === true){
            $errors = 'fillin';
            break 1;
        }
    }
}
if (empty($_POST)=== false && empty($errors) === true){

    $update_data = array(
        'first_name' => $_POST['first_name'],
        'last_name' => $_POST['last_name'],
        'gender' => $_POST['gender'],
        'age' => $_POST['age'],
        'location' => $_POST['location'],
        'about_me' => $_POST['about_me']
    );
    update_user($update_data);
    echo 'updated';
}else if (empty($errors) === false){
    echo $errors;
}
?>
        <form action = "" method = "POST">
        First Name: <input type = "text" name = "first_name" maxlength = "40" placeholder = "First Name" value = "<?php echo $user_data['first_name']; ?>"><br>
        Last Name: <input type = "text" name = "last_name" maxlength = "40" placeholder = "Last Name" value = "<?php echo $user_data['last_name']; ?>"><br>
        Gender: <select type = "text" name = "gender" value = "<?php echo $user_data['gender']; ?>"><option>Select</option><option name = "male" value = "Male">Male</option><option name = "female" value = "Female">Female</option><option name = "othergen" value = "Other">Other</option></select><br>
        Age: <input type = "text" name = "age" maxlength = "3" placeholder = "What's your age?" value = "<?php echo $user_data['age']; ?>"><br>
       Location: <input type = "text" name = "location" maxlength = "100" placeholder = "Your location?" value = "<?php echo $user_data['location']; ?>"><br>
        About Me: <textarea type = "text" name = "about_me" maxlength = "500" placeholder = "Say something about yourself!" value = "<?php echo $user_data['about_me']; ?>"></textarea><br>

        <input type = "submit" value = "submit">
        </form>
根据W3C的定义,没有
属性。相反,值由
标记包装

<TEXTAREA name="thetext" rows="20" cols="80">
    First line of initial text.
    Second line of initial text.
</TEXTAREA>

请不要使用
mysql.*
函数来编写新代码。它们不再得到维护,社区已经开始。看到了吗?相反,你应该学习并使用或。如果你不能决定哪一个,我会帮你的。如果您选择PDO。另请参见性别:在您提供的代码中,您实际上并没有在任何地方调用函数update_user(),因此我对该表没有被调用并不感到惊讶updated@Pankrates是的,我已经意识到了。我换了话题,但我还有一个问题!html代码可能不会导致错误,请提供设置$user\u数据变量并打印其内容的php代码。谢谢,选择框怎么样。我得到了文本区!非常感谢你的回答!
<TEXTAREA name="thetext" rows="20" cols="80">
    First line of initial text.
    Second line of initial text.
</TEXTAREA>
<select name="fieldname">
    <option value="on select,submitted value" <?php echo $myValue == 'on select,submitted value' ? ' selected="selected"' : ''; ?>>displayed value</option>
    <option value="on select,submitted value 2" <?php echo $myValue == 'on select,submitted value 2' ? ' selected="selected"' : ''; ?>>displayed value</option>
</select>