Jump to content

Convert Php If Statements To Mysql


Manny
 Share

Recommended Posts

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...