donvo24600 2013-10-14 20:52
浏览 29

我正在寻找新的更新功能或建议来修复我现有的

In the code I gather data from my database then depending on the values of the data I will update it. I can retrieve the values but I can't update them I need help with the syntax of my update function or a different type of function.

<?php
$con = mysqli_connect("127.0.0.1","root","","timeclock");
if (mysqli_connect_errno($con))
{
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}else{
    echo "connected";
}
$x=2;
timein($x);
function timein($x){
    $con = mysqli_connect("127.0.0.1","root","","timeclock");
    if (mysqli_connect_errno($con))
    {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }else{
        echo "connected";
    }

    $result=mysqli_query($con,"SELECT * FROM emplo`enter code here`yeedatabase WHERE employeeID=$x ORDER BY employeeID" );
    while($row = mysqli_fetch_array($result))
    {
        $inout = $row['inOut'];
    }

    echo $inout;

    if($inout == 1){
        echo "hello";
        $con = mysqli_connect("127.0.0.1","root","","timeclock");
        if (mysqli_connect_errno($con))
        {
            echo "Failed to connect to MySQL: " . mysqli_connect_error();
        }else{
            echo "connected";
        }
        $result=mysqli_query($con,"SELECT * FROM employeedatabase WHERE employeeID=$x ORDER BY employeeID" );
        while($row = mysqli_fetch_array($result))
        {
            $inout = $row['inOut'];
            $row['inOut']=2;
        }
        echo "</table>";

        echo $inout;
        $outa=2;
        mysqli_query($con,"UPDATE employeedatabase SET inOut='$outa' WHERE employeeID='$x'"); 
    }
}

?>-## Heading ##

the mysqli query function is not working I need either a new function or better syntax for my mysqli function.

  • 写回答

1条回答 默认 最新

  • drh47606 2013-10-14 21:13
    关注

    "Not working" isn't very helpful, in future errors and what is put in and does/doesn't happen is helpful.

    But it looks like this line needs changing from

    SELECT * FROM emplo`enter code here`yeedatabase WHERE employeeID=$x ORDER BY employeeID" );
    

    to

    SELECT * FROM employeedatabase WHERE employeeID=$x ORDER BY employeeID" );
    
    评论

报告相同问题?

悬赏问题

  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大