how to convert mysql null as 0 in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kummu4help
    New Member
    • Nov 2008
    • 14

    how to convert mysql null as 0 in php

    hi,
    i am executing a query in php.
    the query returns a result set which may contain NULL for some of the columns

    i want to display this result set as a table.

    when a column has null value i want to display it as 0

    here i am not allowed to use any conditional statement.

    so is there any built in function either in php or mysql that solves my problem

    thanks for any help
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    what about type casting:
    Code:
    echo ((int) $var_that_may_be_null);
    // prints the variable as integer

    Comment

    Working...