始终显示“结果错误”

时间:2017-08-08 09:13:58

标签: php html

当我运行此代码时,始终显示在页面上“结果错误”或“无数据可用”知道我在数据库中添加数据:哪里错了

<?php 
if(isset($_POST['update']))
            {
                    $data = getpost();
                    $search_Query = "SELECT * FROM employee WHERE user_id_assets = $data[0]";
                    $search_result = mysqli_query($conn , $search_Query);

                if($search_result)
                {
                    if( mysqli_num_rows($search_result))
                    {
                        while ($row = mysqli_fetch_array($search_result)) {
                            $user_id_assets = $row['user_id_assets'];
                            $name_emp = $row['name_emp'];
                            $user_account = $row['user_account'];
                            $mail_account = $row['mail_account'];
                    }
                }else{
                    echo "no Data For This User ID";
                }       
            }else {
                echo "result Error";
            }
        } ?>

1 个答案:

答案 0 :(得分:0)

试试这个......

if(isset($_POST['update'])){
    $search_Query = 'SELECT * FROM employee WHERE user_id_assets = '.$_POST['user_id_assets'];
    $search_result = mysqli_query($conn , $search_Query) or mysqli_error($conn);

    if( mysqli_num_rows($search_result)){
        while ($row = mysqli_fetch_array($search_result)) {
            $user_id_assets = $row['user_id_assets'];
            $name_emp = $row['name_emp'];
            $user_account = $row['user_account'];
            $mail_account = $row['mail_account'];
        }
    }else{
        echo "no Data For This User ID";
    }       
}