Hi,
How I can get seasons and under seasons is gamedays and each gameday have his own matches.
(Fifa 2018 is season)
Fifa 2018 - first gameday
PHP VS Help
Help VS PHP
Fifa 2018 - second gameday
PHP VS Help
Help VS PHP
Fifa 2018 - third gameday
PHP VS Help
My code, what I’ve tryed:
[php]<?php
function convertNumberToWord($num = false)
{
$num = str_replace(array(’,’, ’ ‘), ‘’ , trim($num));
if(! $num) {
return false;
}
$num = (int) $num;
$words = array();
$list1 = array(’’, ‘First’, ‘Second’, ‘Third’, ‘Fourth’, ‘Fifth’, ‘Sixth’, ‘Seventh’, ‘Eight’, ‘Ninth’, ‘Tenth’
);
$list2 = array(’’, ‘ten’, ‘twenty’, ‘thirty’, ‘forty’, ‘fifty’, ‘sixty’, ‘seventy’, ‘eighty’, ‘ninety’, ‘hundred’);
$list3 = array(’’, ‘thousand’, ‘million’, ‘billion’, ‘trillion’, ‘quadrillion’, ‘quintillion’, ‘sextillion’, ‘septillion’,
‘octillion’, ‘nonillion’, ‘decillion’, ‘undecillion’, ‘duodecillion’, ‘tredecillion’, ‘quattuordecillion’,
‘quindecillion’, ‘sexdecillion’, ‘septendecillion’, ‘octodecillion’, ‘novemdecillion’, ‘vigintillion’
);
$num_length = strlen($num);
$levels = (int) (($num_length + 2) / 3);
$max_length = $levels * 3;
$num = substr(‘00’ . $num, -$max_length);
$num_levels = str_split($num, 3);
for ($i = 0; $i < count($num_levels); $i++) {
$levels–;
$hundreds = (int) ($num_levels[$i] / 100);
$hundreds = ($hundreds ? ’ ’ . $list1[$hundreds] . ’ hundred’ . ’ ’ : ‘’);
$tens = (int) ($num_levels[$i] % 100);
$singles = ‘’;
if ( $tens < 20 ) {
$tens = ($tens ? ’ ’ . $list1[$tens] . ’ ’ : ‘’ );
} else {
$tens = (int)($tens / 10);
$singles = (int) ($num_levels[$i] % 10);
$singles = ’ ’ . $list1[$singles] . ’ ‘;
}
$words[] = $hundreds . $tens . $singles . ( ( $levels && ( int ) ( $num_levels[$i] ) ) ? ’ ’ . $list3[$levels] . ’ ’ : ‘’ );
} //end for loop
$commas = count($words);
if ($commas > 1) {
$commas = $commas - 1;
}
return implode(’ ', $words);
}
$sql1 = “SELECT id, name FROM seasons WHERE is_ended = 0 ORDER BY date DESC”;
$result = mysqli_query($conn, $sql1) or die(mysqli_error($conn));
$seasons = array();
while ($row2 = mysqli_fetch_assoc($result)) {
$seasons[] = $row2;
}
foreach ($seasons as $key => $season) {
$id = $season[‘id’];
$sql2 = “SELECT game_day FROM matches WHERE is_deleted = 0 AND season_id = ‘{$id}’ AND NOT ‘finished’ ORDER BY date DESC”;
$result2 = mysqli_query($conn, $sql2) or die(mysqli_error($conn));
$gdays = array();
$row4 = mysqli_fetch_assoc($result2);
$gd = $row4[‘game_day’];
$query_Recordset_List = <<<EOF
SELECT
t1.id,
t1.title,
t1.match_date AS dt,
t1.team1_id,
t1.team2_id,
t1.status,
t1.game_day,
t1.stadium,
t2.name AS home_team_name,
t3.name AS away_team_name,
t2.logo AS home_team_logo,
t3.logo AS away_team_logo
FROM matches t1
LEFT JOIN teams t2 ON t1.team1_id = t2.id
LEFT JOIN teams t3 ON t1.team2_id = t3.id
WHERE
t1.is_deleted = 0
AND season_id = ‘{$id}’
AND game_day = ‘{$gd}’
AND NOT ‘finished’
ORDER BY t1.date DESC
EOF;
$Recordset_List = mysqli_query($conn, $query_Recordset_List) or die(mysqli_error($conn));
$totalRows_Recordset_List = mysqli_num_rows($Recordset_List);
$matches = array();
while ($row_Recordset_List = mysqli_fetch_assoc($Recordset_List)) {
if ($use_sef_links == true){
$sef_link = ‘’;
$sef_link .= $row_Recordset_List[‘title’] . ’ ';
$sef_link .= ‘(’ . $row_Recordset_List[‘home_team_name’] . ’ ‘;
$sef_link .= ‘vs ’ . $row_Recordset_List[‘away_team_name’] . ‘) ‘;
$sef_link .= $row_Recordset_List[‘match_date’];
$sef_link = str_replace("-", " ", $sef_link);
$sef_link = preg_replace(’#\s{1,}#’, " “, $sef_link);
$sef_link = str_replace(” ", “-”, $sef_link);
$sef_link = preg_replace(’#[^a-zA-Z0-9-]#’, “”, $sef_link);
$sef_link .= ‘_m’. $row_Recordset_List[‘id’] . ‘.html’;
$row_Recordset_List['link'] = $sef_link;
}
else{
$row_Recordset_List['link'] = 'match.php?id=' . $row_Recordset_List['id'];
}
$matches[] = $row_Recordset_List;
}
?>
<?php foreach ($matches as $key => $match) { ?>
<?php } ?>
<?php } ?>[/php]