dimanche 8 octobre 2017

How to set multiple conditions in if else statement, php

I am trying to set a if statement(s) for a self-processing form that checks if the user entered a positive whole number for quantity. This would be the following conditions:

is_numeric

is_int

and > 0

I've read that I can use || and && to set multiple conditions in a single if function, however it's not working because when I typed "-1" or "jkgh" as quantity, it still printed the table row.

If statement:

    if (is_numeric($_POST['qty_entered'][0]) || is_int($_POST['qty_entered'][0]) || $_POST['qty_entered'][0] > 0) {
    print "'<tr><td>' test '</td>'";

Thanks!

Aucun commentaire:

Enregistrer un commentaire