Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2007
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Need a quick code snippet.

    I was wondering how to make it so if I dont enter a value into a form it will automaticly put zero in it. Is that what zero fill is in mysql? Sorry guys, I am still a noob trying to learn.

  • #2
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    default it to 0 via phpmyadmin?

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    If it's a number use intval() or typecast it to an integer. If it's a string use something like:
    PHP Code:
    $value = (!empty($_POST['var']) ? $_POST['var'] : 0); 
    or if/else.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •