SitePoint Sponsor

User Tag List

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

    Question while (excluding records)

    I want to do:

    PHP Code:
    while ($row mysql_fetch_array($result)) {
            
    $variable1 $row["variable1"];
            
    $variable2 $row["variable2"];
        } 
    but I want to add something like this:

    PHP Code:
    while ($row mysql_fetch_array($result))
        AND (
    $variable3 yes)  {
            
    $variable1 $row["variable1"];
            
    $variable2 $row["variable2"];
        } 
    This should exclude records where $variable3 = no

    What is the correct logic / formatting to do this?

    Thanks,
    Jeff

  2. #2
    purple monkey dishwasher scoates's Avatar
    Join Date
    Nov 2001
    Location
    Montreal
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    while ($row mysql_fetch_array($result)) {
        if (
    $variable3 == "yes") {
            
    $variable1 $row["variable1"];
            
    $variable2 $row["variable2"];
        }

    I think that's what you're looking for.

    S

  3. #3
    SitePoint Zealot jsk137's Avatar
    Join Date
    Jan 2002
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, I needed to suppress the display when $test3 == yes. So here is what worked for me.

    PHP Code:
    while ($row mysql_fetch_array($result)) {
            
    $variable1 $row["variable1"];
            
    $variable2 $row["variable2"];
        if (
    $variable3 == "no") {
            echo 
             
    $variable1 
             $variable2
        
    }

    This worked so that when $variable3 was yes nothing happened for that record.

    Thanks Sean for your help.


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
  •