Jump to content

A little help here


JJohnsenDK

Recommended Posts

Hey

I have these two tables:

seasons:
seasons_ID: 1 - year: 2006
seasons_ID: 2 - year: 2005
seasons_ID: 3 - year: 2004

actions:
game_ID: 1 - season_ID: 1
game_ID: 2 - season_ID: 1

And this query:
[code]
<?php
//query
$sql = "SELECT MAX(s.year) AS year
          FROM seasons AS s
          LEFT JOIN actions AS a ON s.seasons = a.season_ID";
$result = mysql_query($sql) or die(mysql_error());

$row = mysql_fetch_array($result);

//This if code says if year(2006) is = season_ID(1) print this
if($row['year'] == $row['season_ID']){
?>
<table>
  <tr>
    <td>View this text</td>
  </tr>
</table>
<?php
}else{
  echo "No data";
}
?>
[/code]

This code is just a fast example on what i need. As i wrote in the comment over this if statement the two numbers doesnt match. My quesstion is: How do i get the season_ID to be equal to year? Or if you see a total different way to do this plz tell. I could change the season_ID to 2006, but that would be duplication because i also use the seasons table elsewhere.

Any help would be great :)
Link to comment
https://forums.phpfreaks.com/topic/32944-a-little-help-here/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.