我试图在数据插入MySQL查询之前进行检查.这是代码;
$userid = ($vbulletin->userinfo['userid']);
$sql3 = mysql_query("SELECT * FROM table WHERE ID='$_POST[hiddenID]'");
while ($row = mysql_fetch_array($sql3)){
$toon = $row['toonname'];
$laff = $row['tlaff'];
$type = $row['ttype'];
if ($type == 1){
$type == "Bear";
} elseif ($type == 2){
$type == "Cat";
} elseif ($type == 3){
$type == "Dog";
}
}
Run Code Online (Sandbox Code Playgroud)
但是,这不起作用.基本上,每种类型的"表格"中都有不同的值.1表示熊,2表示猫,3表示狗.
感谢任何人可以帮助我在脚本中查看问题!
我目前正在我的网页上使用此代码:
<?php
$url = "https://www.toontownrewritten.com/api/invasions";
$data = json_decode(file_get_contents($url));
if (!empty($data->invasions)) {
echo "<h1 style='text-align:center;margin:auto;padding:2px;font-size:16px;font-weight:bold;text-decoration:underline;padding:2px;'>Invasion Tracker</h1>";
$i = 0;
foreach($data->invasions as $title => $inv) {
print "<h3 style='text-align:center;margin:auto;'><b>District:</b> {$title}
</h3><br style='font-size:1px;'><h3 style='text-align:center;margin:auto;'><b>Cog:</b> {$inv->type}
</h3><br style='font-size:1px;'><h3 style='text-align:center;margin:auto;'><b>Progress:</b> {$inv->progress}
</h3>";
if (count(($data->invasions) > 1)) {
if (end($data->invasions) !== $inv) {
print "<hr>";
} else {
print "<br style='font-size:2px;'>";
}
}
}
} else {
echo "<h1 style='text-align:center;margin:auto;padding:2px;color:darkred;font-weight:bold;'>No invasions!</span>";
}
?>
Run Code Online (Sandbox Code Playgroud)
我希望通过AJAX每10秒刷新一次.但是,我一直在读你需要创建一个函数,但我不确定我是如何使用API的呢?每10秒,该API正在更新,这就是为什么我希望每10秒用AJAX更新一次.目前,我有它,所以用户必须手动刷新.任何帮助表示赞赏!