SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2002
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    If Loop and Variable Problems

    I'm sure this is an easy fix, but I can't figure it out from my book and the archives. I have a variable and I want to display it in the else part of an if/else statement. It won't display it. Do I need to pass it to the else or something?

    PHP Code:
    $Base '1';
    echo 
    "Test " $Base//Display's variable.
        
    if ($num_results 1//From sql results.
        
    {
            echo 
    "Base: $" $row["row"] . "<br>";    }
        else
        {    
            echo 
    "Base: $" $Base//Won't display $Base variable    


  2. #2
    SitePoint Wizard silver trophy Jelena's Avatar
    Join Date
    Feb 2005
    Location
    Universum, 3rd Corner
    Posts
    3,001
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The if is a problem.. You should state it like:

    if ($num_results == 1)
    -- Jelena --

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2002
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Heh. Wow, i'm tired. Thanks jelena. I knew it was simple.


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
  •