我想再制定一条规则,该规则告诉我彩票的6个数字是否已经赢了,该代码显示了一个数字出现了多少次,但是我想再制定一条规则,即选择数据库中已有的6个数字,例如选择另一个数字。我想我可以使用Json,您怎么看?
<form method="post" action="verificador.php">
<input style="width:41px;height:33px;border-radius:50%;" type="text" name="chk1">
<input style="width:41px;height:33px;border-radius:50%;" type="number" name="chk2">
<input style="width:41px;height:33px;border-radius:50%;" type="number" name="chk3">
<input style="width:41px;height:33px;border-radius:50%;" type="number" name="chk4">
<input style="width:41px;height:33px;border-radius:50%;" type="number" name="chk5">
<input style="width:41px;height:33px;border-radius:50%;" type="number" name="chk6">
<input style="width:41px;height:33px;border-radius:50%;" type="number" name="chk7">
<input style="width:20%;height:33px;border-radius:10%" type="submit" name="Chequear" value=Chequear>
$sql = "SELECT COUNT(*) AS Count FROM bolas WHERE bola1='$bola1' or bola2='$bola1'or bola3='$bola1'or bola4='$bola1' or bola5='$bola1'or bola6='$bola1'or bola7='$bola1'";
$sqldos ="SELECT COUNT(*) AS Countdos FROM bolas WHERE bola2='$bola2' or bola1='$bola2' or bola3='$bola2'or bola4='$bola2'or bola5='$bola2' or bola6='$bola2'or bola7='$bola2'";
$sqltres ="SELECT COUNT(*) AS Counttres FROM bolas WHERE bola3='$bola3'or bola1='$bola3' or bola2='$bola3'or bola4='$bola3'or bola5='$bola3' or bola6='$bola3'or bola7='$bola3'";
$sqlcuatro ="SELECT COUNT(*) AS Countcuatro FROM bolas WHERE bola4='$bola4'or bola1='$bola4' or bola2='$bola4'or bola3='$bola4'or bola5='$bola4' or bola6='$bola4'or bola7='$bola4'";
$sqlcinco ="SELECT COUNT(*) AS Countcinco FROM bolas WHERE bola5='$bola5'or bola1='$bola5' or bola2='$bola5'or bola3='$bola5'or bola4='$bola5' or bola6='$bola5'or bola7='$bola5'";
$sqlseis ="SELECT COUNT(*) AS Countseis FROM bolas WHERE bola6='$bola6'or bola1='$bola6' or bola2='$bola6'or bola3='$bola6'or bola4='$bola6' or bola5='$bola6'or bola7='$bola6'";
$sqlsiete ="SELECT COUNT(*) AS Countsiete FROM bolas WHERE bola7='$bola7'or bola1='$bola7' or bola2='$bola7'or bola3='$bola7'or bola4='$bola7' or bola5='$bola7'or bola6='$bola7'";
$result=$conn->query($sql);
$row = $result->fetch_assoc();
$resultdos=$conn->query($sqldos);
$rowdos = $resultdos->fetch_assoc();
$resulttres=$conn->query($sqltres);
$rowtres = $resulttres->fetch_assoc();
$resultcuatro=$conn->query($sqlcuatro);
$rowcuatro = $resultcuatro->fetch_assoc();
$resultcinco=$conn->query($sqlcinco);
$rowcinco = $resultcinco->fetch_assoc();
$resultseis=$conn->query($sqlseis);
$rowseis = $resultseis->fetch_assoc();
我希望使用json或mysql查询
答案 0 :(得分:0)
您可以将其缩小为一个sql:
$values = "$bola1,$bola2,$bola3,$bola4,$bola5,$bola6,$bola7";
select count(*) as total from bolas
where bola1 in ($values) and bola2 in ($values)
and bola3 in ($values) and bola4 in ($values)
and bola5 in ($values) and bola6 in ($values) and bola7 in ($values)