私の PHP では、チームのリストであるデータベースに SQL クエリを作成します。一部のチームでは、クエリは null を返します。phpmyadmin で同じクエリを作成すると、探している値が返されます。
私のクエリコード:
$sql = $mysqli->query("
SELECT `team`
FROM `dota teams`
WHERE `team` LIKE '%$team%'
OR `teamalt` LIKE '%$team%'
") or die($mysqli->error);
たとえば、私のウェブサイトからのクエリが te の場合は null を返しますが、クエリが titan の場合は Titan Esports を返します。また、Virtus Pro では、vp または virtus を使用すると、必要な値が返されます。NAVI では null を返します。Evil Geniuses は、EG または Evil と記述した場合にも値を返します。
ある名前では戻り値を取得し、一部の名前では返さないのはなぜですか?
完全な PHP コード:
$date = $mysqli->real_escape_string(date("d\-m\-Y"));
$team = set_space($team); //Set spaces in teams so we can ute it for search
// Get team name
$sql = $mysqli->query("
SELECT `team`
FROM `dota teams`
WHERE `team` LIKE '%$team%'
OR `teamalt` LIKE '%$team%'
") or die($mysqli->error);
if($sql->num_rows>0){
$team = $sql->fetch_array();
$team = $team['team'];
// Get all the matches
$sql = $mysqli->query("
SELECT * FROM `dota schedule`
WHERE `date` >= '$date' AND `teams`
LIKE '%$team%' ORDER BY `date`,`time` ASC
") or die($mysqli->error);
// Loop through all the results
while ($data = $sql->fetch_array()){
// Change the time based on timezone
$time_arr = str_split($data['time'],3);
$hour = $time_arr[0] + $time_add;
$min = str_replace(":","",$time_arr[1]);
$time = "$hour : $min";
// Get teams
$teams = get_teams($data['teams']);
// Get casters
$caster = explode('_', $data['caster']);
foreach($caster as &$c){
$c = get_string_between($c,'[',']');
}
// Loop through to see which language the casters has.
foreach($caster as &$c){
$sqls = $mysqli->query("SELECT `language` , `stream` FROM `dota casters` WHERE `name` = '$c'") or die($mysqli->error);
$da = $sqls->fetch_array();
if($da['language'] == "English"){
$stream = $da['stream'];
$c = "<a href='$stream'><img src='http://joffe.kottnet.eu/flags/uk.png' alt='English'>$c</a>";
}
else if($da['language'] == "Russia"){
$stream = $da['stream'];
$c = "<a href='$stream'><img src='http://joffe.kottnet.eu/flags/russia.png' alt='English'>$c</a>";
}
}
?>
// Write out table.
<tr>
<td><?= "Date:" . $data['date'] . " Time: " .$time?></td>
<td><?= $data['cup'] ?></td>
<!-- 3 TD for teams -->
<td class="team1"><?= $teams[0] ?></td>
<td class="vs">VS</td>
<td><?= $teams[1] ?></td>
<td><?= print_out_array($caster); ?></td>
</tr>
<?php
}
}