Manny Posted February 12, 2010 Share Posted February 12, 2010 I'm currently redeveloping my website. To give a basic background, it's a football website and this section is a Prediction League.Below is a PHP MySQL piece of code which is given a variety of if statements to determine the "Perfect", "Outcome" and "Goalscorer" records which are to be used to work out the points system.In my code those three are set as variables, but they do not actually exist in the database. I was wondering if somebody could be a huge help to me and somehow help me convert the IF statements into an SQL statement. <?$sqlstatement = "SELECT * FROM `prediction_league_fixtures`";$sql_result = mysql_query($sqlstatement,$connection) or die("<p>Content could not be displayed.</p>");echo '<table><tr><td colspan="3"></td><td>P</td><td>O</td><td>G</td></tr>';//variableswhile ($row = mysql_fetch_array($sql_result)){ echo '<tr><td>', $row["MatchID"], '</td><td>', $row["memberName"], '</td><td>', $row["Club"], '</td><td>'; if(($row["F"] == $row["PF"]) && ($row["A"] == $row["PA"])) { $row["Perfect"] = '1'; echo $row["Perfect"]; } echo '</td><td>'; if(($row["F"] > $row["A"]) && ($row["PF"] > $row["PA"]) || ($row["F"] == $row["A"]) && ($row["PF"] == $row["PA"]) || ($row["F"] < $row["A"]) && ($row["PF"] < $row["PA"])) { $row["Outcome"] = '1'; echo $row["Outcome"]; } echo '</td><td>'; if($row["Scorer"] == $row["PScorer"]) { $row["Goalscorer"] = '1'; echo $row["Goalscorer"]; } echo '</td></tr>';}echo '</table>';?> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.