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.