Hello,
I need some help in this code:
I added a column to my database:
image_gameI created also a new tabel: zu_games (zu_game_id, zu_games_game..)
For example: I have 10 images on my galery. 5 images from the game1 and 5 images from the game2. So the field image_game has the value game1. And also the other 4 image_game. Clear?
As result I want something like:
Games | Image ids |
Game1 | 1, 2, 3, 4, 5 |
Games2 | 6, 7, 8, 9, 10 |
With the following code I got this result. That means he get only 1 image id instead of everything.
Games | Image ids |
Game1 | 1 |
Games2 | 6 |
$sql = "SELECT *, i.image_id, i.image_game
FROM (".ZU_GAMES_TABLE." g)
LEFT JOIN (".IMAGES_TABLE." i) ON (i.image_game = g.zu_games_game)
WHERE zu_games_game LIKE '%$zu_games_team1%' AND zu_games_game LIKE '%$zu_games_team2%'
GROUP BY zu_games_game
ORDER by g.zu_games_date ASC
";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
if (!$num_rows) {
$zu_game_teams_games = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\"><tr><td>No info</td></tr>";
}
else {
$zu_game_teams_games = "<table class=\"head2\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\">
<tr><td><b>#</b></td>
<td><b>Date</b></td>
<td><b>Game</b></td>
<td><b>Videos</b></td>
</tr>
";
$i = 1;
while ($zu_games_row = $site_db->fetch_array($result)){
$zu_games_date = date("d-m-Y", $zu_games_row['zu_games_date']);
$day = substr($zu_games_row['zu_games_day'], 0, 2);
$image_game2 = "".$zu_games_row['image_id'].", ";
$image_id_videos = substr($image_game2, 0, -2);
$zu_game_teams_games .= "<tr>
<td valign=\"top\" class=\"sortable\"><b>".$i++."</b></td>
<td valign=\"top\">".$day." ".$zu_games_date."</td>
<td valign=\"top\"><a href=\"".$site_sess->url(ROOT_PATH."zu_games.php?zu_games_id=".$zu_games_row['zu_games_id'])."\">".$zu_games_row['zu_games_game']."</a></td>
<td>".$image_id_videos."</td>
</td></tr>
";
}
}
$zu_game_teams_games .= "</table>\n";
$site_template->register_vars("zu_game_teams_games", $zu_game_teams_games);
unset($zu_game_teams_games);
I apreciate any help.
Cruxy