所以基本上有一个脚本可以检查用户号码(他们选择)与另一个数字表格。 该脚本会检查它们匹配的数量并将其更新为用户行。
我遇到的问题是,当它更新所有用户时,它会使用第一个用户编号,并更新他们在每个用户上匹配的数量。
剧本很乱,很遗憾。
<?
include "../includes/db_connect.php";
$sql="SELECT * from users WHERE status='Alive'";
$result=mysql_query($sql);
$number = 0;
$number_wrong = 0;
while($rows=mysql_fetch_array($result)){ // Start looping table row
$one2=$rows['1'];
$two2=$rows['2'];
$three2=$rows['3'];
$four2=$rows['4'];
$five2=$rows['5'];
$six2=$rows['6'];
$q = mysql_query("SELECT * FROM `numbers` WHERE `1` = '$one2' OR `2` = '$one2' OR `3` = '$one2' OR `4` = '$one2' OR `5` = '$one2' OR `6` = '$one2' ");
$get = mysql_num_rows($q);
if($get == 0) {
++$number_wrong;
} else {
++$number;
}
$q23 = mysql_query("SELECT * FROM `numbers` WHERE `1` = '$two2' OR `2` = '$two2' OR `3` = '$two2' OR `4` = '$two2' OR `5` = '$two2' OR `6` = '$two2' ");
$get23 = mysql_num_rows($q23);
if($get23 == 0) {
++$number_wrong;
} else {
++$number;
}
$q2 = mysql_query("SELECT * FROM `numbers` WHERE `1` = '$three2' OR `2` = '$three2' OR `3` = '$three2' OR `4` = '$three2' OR `5` = '$three2' OR `6` = '$three2' ");
$get2 = mysql_num_rows($q2);
if($get2 == 0) {
++$number_wrong;
} else {
++$number;
}
$q3 = mysql_query("SELECT * FROM `numbers` WHERE `1` = '$four2' OR `2` = '$four2' OR `3` = '$four2' OR `4` = '$four2' OR `5` = '$four2' OR `6` = '$four2' ");
$get3 = mysql_num_rows($q3);
if($get3 == 0) {
++$number_wrong;
} else {
++$number;
}
$q4 = mysql_query("SELECT * FROM `numbers` WHERE `1` = '$five2' OR `2` = '$five2' OR `3` = '$five2' OR `4` = '$five2' OR `5` = '$five2' OR `6` = '$five2' ");
$get4 = mysql_num_rows($q4);
if($get4 == 0) {
++$number_wrong;
} else {
++$number;
}
$q5 = mysql_query("SELECT * FROM `numbers` WHERE `1` = '$six2' OR `2` = '$six2' OR `3` = '$six2' OR `4` = '$six2' OR `5` = '$six2' OR `6` = '$six2' ");
$get5 = mysql_num_rows($q5);
if($get5 == 0) {
++$number_wrong;
} else {
++$number;
}
}
$sql="SELECT * from users WHERE status='Alive' ORDER by id ASC";
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result)){ // Start looping table row
$membernames=$rows['email'];
$query = "UPDATE `users` SET `number` = '$number' WHERE `email` = '$membernames'";
mysql_query($query) or die ("Error in query: $query");
}
?>