Im am trying to make a "tournament" application, and get stuck on viewing data from 6 different tables!
I have 6 tabels that I can put data in at the same time, but I can't view it together! And have tried to search on the internet for hours, but I just can't get it...
Any way. It is an 4 team tournament with wins, draws, lose and point. And I have 6 tables for this:
- Tournament name - ID, name
- Teams - ID, team1, team2, team3, team4
- Wins - ID, team1w, team2w, team3w, team4w
- Draws ID, team1d, team2d, team3d, team4d
- Looses - ID, team1l, team2l, team3l, team4l
- Points - ID, team1p, team2p, team3p, team4p
Thats whats in the Tables...
This is my input, it works fine..
<?php
if(isset($_POST['submit'])) {
$cupname = $_POST['cupname'];
$team1 = $_POST['team1'];
$team2 = $_POST['team2'];
$team3 = $_POST['team3'];
$team4 = $_POST['team4'];
$zero = "0";
$result = mysql_query("INSERT INTO cupname (name) VALUES ('$cupname')");
$result = mysql_query("INSERT INTO teams (team1, team2, team3, team4) VALUES ('$team1', '$team2', '$team3', '$team4')");
$result = mysql_query("INSERT INTO wins (team1w, team2w, team3w, team4w) VALUES ($zero, $zero, $zero, $zero)");
$result = mysql_query("INSERT INTO draws (team1d, team2d, team3d, team4d) VALUES ($zero, $zero, $zero, $zero)");
$result = mysql_query("INSERT INTO looses (team1l, team2l, team3l, team4l) VALUES ($zero, $zero, $zero, $zero)");
$result = mysql_query("INSERT INTO points (team1p, team2p, team3p, team4p) VALUES ($zero, $zero, $zero, $zero)");
echo "<h1>Turnering og lag lagt til!</h1>";
}
?>
That's the start out of making a "league/tournament". And all the data get's in the tables.
And I got this code from an tutorial I used to make a simple on-site editing for my webpage. And though mabey I could use the same output code, but on that site it's only news from a single table.
I have read some about UNION, LEFT JOIN, FULL JOIN etc.... But I didn't get it.
Here is my "output" code:
<?php
$result = mysql_query("SELECT * FROM cupname ORDER BY id DESC");
$result = mysql_query("SELECT * FROM teams ORDER BY id DESC");
$result = mysql_query("SELECT * FROM wins ORDER BY id DESC");
$result = mysql_query("SELECT * FROM draws ORDER BY id DESC");
$result = mysql_query("SELECT * FROM looses ORDER BY id DESC");
$result = mysql_query("SELECT * FROM points ORDER BY id DESC");
while($row = mysql_fetch_array($result)) {
$i=$i + 1;
echo "<table>";
echo "<tr>";
echo $row['name'];
echo "</tr>";
echo "<tr><td><b>Lag</b></td>
<td><b>Seiere</b></td>
<td><b>Uavgjort</b></td>
<td><b>Tap</b></td>
<td><b>Poeng</b></td>
</tr><tr><td>";
echo $row['team1'];
echo "</td><td>";
echo $row['team1w'];
echo "</td><td>";
echo $row['team1d'];
echo "</td><td>";
echo $row['team1l'];
echo "</td><td>";
echo $row['team1p'];
echo "</td></tr><tr><td>";
echo $row['team2'];
echo "</td><td>";
echo $row['team2w'];
echo "</td><td>";
echo $row['team2d'];
echo "</td><td>";
echo $row['team2l'];
echo "</td><td>";
echo $row['team2p'];
echo "</td></tr><tr><td>";
echo $row['team3'];
echo "</td><td>";
echo $row['team3w'];
echo "</td><td>";
echo $row['team3d'];
echo "</td><td>";
echo $row['team3l'];
echo "</td><td>";
echo $row['team3p'];
echo "</td></tr><tr><td>";
echo $row['team4'];
echo "</td><td>";
echo $row['team4w'];
echo "</td><td>";
echo $row['team4d'];
echo "</td><td>";
echo $row['team4l'];
echo "</td><td>";
echo $row['team1p'];
echo "</td></tr></table><br /><hr /><br />";
}
?>
Anyone have any idea of what I shall do, or not do ?
Thanks for any answers!
EDIT: I just get an output of empty tables with this! Only the points is outputted, the 0's.