SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict
    Join Date
    Jul 2005
    Posts
    215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What is the Value of Blank Table Cell???

    I have two tables as shown below:

    Table 1: Actor.............................Table 2: Movie
    Field:...ID.....Last......First..............Field:...ID.....Last......Movie
    ...........1.....Willis......Bruce.......................1.....Willis......Die Hard
    ...........2 ....Cruze....Tom..........................2.....Cruze.....MI-III
    ...........3.....Pitt.......Brad
    ...........4 ....Depp.....Johnny

    Then I JOIN the tables with Query which works fine, following is the result:
    Field:...Last......First........Movie
    ..........Willis......Bruce......Die Hard
    ..........Cruze....Tom.........Cruze MI-III
    ..........Pitt.......Brad
    ..........Depp.....Johnny

    MY QUESTION: What is stored in the Movie column for Brad Pitt and Johnny Depp? Is that value NULL? or is that value EMPTY? What is it?
    Because I want to create IF clause as follows:
    IF ($Movie = String)
    { Do this }
    else
    { Do that }

    I appriciate this very much. Hope this makes sense.
    Last edited by jjdave; Nov 20, 2007 at 15:30. Reason: Better Understanding of Tables

  2. #2
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    the default value of a column is based on what you set it to be, and what data type it is.
    most like

    if ($movie == '') for checking if its empty should work based on the assumption that your column type is varchar.

  3. #3
    SitePoint Addict
    Join Date
    Jul 2005
    Posts
    215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, in table Movie, I have two other fields:
    1. ID which is INT data type
    2. Movie which is VARCHAR data type

    So what would be the value?

  4. #4
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    varchar by default is empty string ""

    and int by default is 0

  5. #5
    SitePoint Evangelist catweasel's Avatar
    Join Date
    Apr 2007
    Location
    Goldfields, VIC, Australia
    Posts
    518
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the example you've given it would be null.. you can check for it like this -

    PHP Code:
    if (!empty($movie)) echo $movie
    I think in your movie table, instead of using the actor's last name use their id.. call it actor_id

  6. #6
    SitePoint Addict
    Join Date
    Jul 2005
    Posts
    215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank You wonshikee & catweasel

    What I thought was right, about VARCHAR as "" and INT as 0. I also checked the !empty for the NULL.

    I think I might have problem with other code that are mixed in to the problem I just mentioned.

    Once again, Thank you and I need to check my algorithm and recheck my code.

  7. #7
    SitePoint Addict
    Join Date
    Jul 2005
    Posts
    215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank You wonshikee & catweasel
    Solution you provided was correct: VARCHAR as "" and INT as 0 and !empty as NULL. They all work fine.

    I found the problem in my sentex structure on Rollover link. I forgot to put Single Quote in A HREF. I fixed it as below and it works fine now.
    PHP Code:
    echo "<A HREF='movie_data.php?$URLvar3'><b>$Last</b></A>"
    Once again, Thank you.
    jjdave...


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
  •