我想验证来自DB的详细信息,这个调用是否可以在DB中使用。此代码正常工作,但仅限第1行,例如,ID为123 CLI - 567,持续时间为00:01:00已经可用,第二个呼叫持续时间为00:01:01也可用。但是这段代码不是检查第二行并带我去别的声明。
<?php
$con=mysqli_connect("localhost","root","","test");
$check="SELECT * FROM eval WHERE empid = '$_POST[empid]' AND cli = '$_POST[cli]' AND callduration = '$_POST[callduration]' ";
$rs = mysqli_query($con,$check);
$data = mysqli_fetch_array($rs, MYSQLI_NUM);
if($data > 0 ) {
echo "Record already exist...<br/>";
}
else
{
echo "<a href='NewUser.php'> New Sign Up </a>
}
?>
答案 0 :(得分:0)
尝试使用mysqli_num_rows
,因为mysqli_fetch_array
可以获得每条记录,并且可以循环播放它们。现在使用mysqli_num_rows
,您可以计算所有记录,并且可以处理记录是否存在。
<?php
$con = mysqli_connect("localhost","root","","test");
$query = "SELECT *
FROM eval
WHERE empid = '".$_POST['empid']."'
AND cli = '".$_POST['cli']."'
AND callduration = '".$_POST['callduration']."'";
$result = mysqli_query($con, $query);
$data = mysqli_num_rows($result);
if($data > 0 ) {
echo "Record already exist...<br/>";
} else {
echo "<a href='NewUser.php'> New Sign Up </a>
}
?>
按要求提供我的测试查询
$query = "SELECT *
FROM user
WHERE user_name = '".$_POST['user_name']."'
AND user_mail = '".$_POST['user_mail']."'";