SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2010
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Conditional insert

    Hi, i have a php table with 7 rows, which sometimes are not all required. Is it possible to do a conditional insert if fields not empty?

    At the moment all 7 rows are inserted regardless of whether only 1 or 2 rows are filled.

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,411
    Mentioned
    149 Post(s)
    Tagged
    4 Thread(s)
    PHP table?
    Do you mean a MySQL table?

    7 rows?
    Do you mean columns?

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2010
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LOL :S - yeah, sorry. I obviously need some sleep.

  4. #4
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,411
    Mentioned
    149 Post(s)
    Tagged
    4 Thread(s)
    When you insert a row in a table, all columns are inserted. Of course, not all columns have to have a "meaningful" value, they may be NULL or spaces or zero.

  5. #5
    SitePoint Enthusiast
    Join Date
    Aug 2010
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. I am filtering !=' ' from the results, so nearly what i wanted.


Bookmarks

Posting Permissions

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