Forum Moderators: coopster
I'm trying to do something but I don't know how to do it. This is why i'm here!
I have hockey games results. What i want to do is if the game goes in overtime i want to show the column "overtime" but if there was no overtime during the game i dont want to see this column. How can i do this?
Table : schedule
columns : home,away,homepoints,awaypoints,homeotpoints,awayotpoints
Hopefully you haven't actually used a CHAR type column to store the strings "YES" or "NO" (although that's not the worst thing in the world to have done) - use a BOOL (TINYINT(1)) type column to store a 0 or 1 state instead.
The query should just retrieve whatever is in the table, as long as there is a value in the `overtime` field, then your PHP code should look at the returning values in the resultset and create a conditional based on this, e.g.
//... executed query at this point, staring loop through records
while( $row= mysql_fetch_assoc($resultset) ) {
// ... whatever process you go through here to create the data output
if ( $row['overtime'] === 0 ) {
// no overtime
// show a "NO" or leave the TD cell blank (use )
} else {
// there was overtime, ooh exciting!
// show a "YES" or something in the cell
}
}
Alternatively, you could just leave the values "YES" or "NO" in the database and print out the column.
Is that what you're looking for?
What i want to do with this query is to add a game in my table. So if Gino played 12 games and i do this query then i would have the result of 13. But instead of getting 13 i get 1? Why?
Thanks guys for your help!