Hello i want a PHP code that can get me the rest of a division i want to know if a number is odd or even so i divide it into 2 if it is odd there will be a rest of the divison if it's even the rest of the division will be 0 any ideas how can i do that? cheers Adel
You're looking for the MODULO operator if ($x % 2 == 0) even the % operator returns the remainder from a division. It is always an integer
hmm another question if i want to redirect the page to another page if the number is even what should i do?
there is another problem in this code because $count++ it doesnt count because the number isnot stored so i think we should store the number first then read it and then we make the increment because when i added echo "$count" ; it alwasy show 1 when i refresh the page
you can try: session_start(); session_register("count"); if (!isset($_SESSION)) { $_SESSION["count"] = 1; } else { $_SESSION["count"]++; } if($_SESSION["count"] % 2) header( 'Location: http://www.yoursite.com/new_page.html' ) ; PHP: