if statement help in php

Soldato
Joined
7 Jan 2007
Posts
10,607
Location
Sussex, UK
I have the following as an if statement:

PHP:
if ($ThisWeeksResults != $LastWeeksResults) {
	print '$ThisWeeksResults';
	}
	else {
	print 'either the numbers are equal to each other or there isnt numerics in this weeks results';
	}

How do I make sure that the if statement checks that $ThisWeeksResults isn't equal to $LastWeeksResults AND that $ThisWeeksResults is_numeric?
 
If your learning, split it down so you have simple error messages so you know where its going wrong, nothing wrong with that code though.

i.e.

Code:
if (!is_numeric($ThisWeeksResults)){
  Print 'This week not numeric';
}else{
  if($ThisWeeksResults != $LastWeeksResults){
      Print 'This weeks  result';
  }else{
      Print 'Numbers are identical';
  }
}

Depends where $ThisWeeksResults is coming from though whether you need it, if its a calculation your calculation should have the error, if its user input then that should have some error checking before submits it.
Just before its printing is really the last place you wanna see someone as basic as is it numeric.
 
Last edited:
Back
Top Bottom