Hi,

I am developing a website for a club and I am trying to get the next games to show up.

I am trying to get some info out of one database and then use that info as a key for the next query, then display all the results that correspond to those queries. Hope that makes sense.

The code I have done so far is:
Please help, I have never done this before..

<?php

	$upcomingGames=array();
	$teamsSql = 'SELECT * FROM teams';
	foreach ($conn->query($teamsSql) as $row) {
		$teamArray[]= $upcomingTeam = $row['team'] && $upcomingRound = $row['round'] &&	$league = $row['league'] &&	$leagueURL = urlencode($row['league']) && $teamURL = urlencode($row['team']);
		foreach ($conn->query("SELECT * FROM fixtures_results WHERE `team`='".$upcomingTeam."' AND `round`='".$upcomingRound."'") as $gameRow) {
			$upcomingGames[]=<<<END
			<tr>
			<td><div class="upcomingGamesLeague"><a href="fixtures.php?leagueName=$leagueURL&teamName=$teamURL">$league:</a></div></td>
			<td><div class="upcomingGamesTeams"><a href="http://$gameRow[home_team].site.com.au" target="_blank">$gameRow[home_team]</a> V <a href="http://$gameRow[away_team].site.com.au" target="_blank">$gameRow[away_team]</a></div></td>
			<td><div class="upcomingGamesDate">$gameRow[day] $gameRow[date] $gameRow[time]</a></div></td>
			</tr>
			
END;
		}
	}
	$upcomingGames=implode("\r\n",$upcomingGames);

?>

Thanks,

Cheers,

QWaz

Recommended Answers

All 2 Replies

Select * from teams t join fixtures_results f on t.team = f.team and t.round = f.round

Member Avatar for rajarajan2017

If you are going to fetch a single field from first query or one more values?
If a single value:

Then store it in a $infokey="that value";

Then pass it to another query: "select * from nextQuery where field=$infokey"

This is somewhat I understand!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.