I have done this several times before but I really can't understand why the code below doesn't work: Any help is welcome, thanks. <? $sql = "SELECT SubmittedBy FROM Game WHERE Game.AddressCheatExtreme = '$AddressCheatExtremen'"; $query = mysql_query($sql); while($result = mysql_fetch_array($query)) $SubmittedBy['test']; if ( $test == "SimonM" ) { echo "Display this text <br />"; } ?> PHP:
I think I see what you need to do, but I would do it like this (don't worry, it's very similar). <?php $sql = "SELECT SubmittedBy FROM Game WHERE Game.AddressCheatExtreme = '$AddressCheatExtremen'"; // Your original SQL statement $query = mysql_query($sql) or die (mysql_error()); // execute the query on the database while($result = mysql_fetch_array($query)) { // The opening of the while loop - notice the { (curly brace) $sub_by = $result['SubmittedBy']; // This is variable that holds the current result of the query if($sub_by == "SimonM") { // If the current result == "SimonM", do this echo "Display this text if SubmittedBy = SimonM"; // Show this if SubmittedBy is equal to SimonM } else { // Remove this else statement if you don't need it, or if there are a lot of results to go through echo "SubmittedBy is not SimonM<br />"; } // The closing of the IF statement } // This is the end of the while loop ?> PHP: I think the problem was you didn't end your while loop, and you didn't start it with the curly brace. I hope that helps