Thread: Loop statement

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Norcross, GA
    Posts
    458
    Rep Power
    15
    If I wanted to test the field swdoc in the array $result for data, how would this be done?

    I was thinking:

    if $myrow["swsetup"] == '' {

    dostuff
    } else {

    dootherstuff
    }

    Not sure how far off the mark I am.

    Also, after I check the field would I have to refresh the array with mysql_data_seek before printing the result?


    current, working, code example:

    while ($myrow = mysql_fetch_array($result))
    {

    echo "<td bgcolor=325f61 width=100 valign="top"><p>";

    printf("%s", $myrow["swdoc"]);

    echo "</p></td>n";
    }
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    <<
    if $myrow["swsetup"] == '' {

    dostuff
    } else {

    dootherstuff
    }
    >>

    if you are checking this out side the loop then it will be checking only one row of that resultset.

    so you can check this value directly in side the loop.

    while ($myrow = mysql_fetch_array($result))
    {
    if $myrow["swsetup"] == 'somevalue' {
    echo "<td bgcolor=325f61 width=100 valign="top"><p>";

    printf("%s", $myrow["swdoc"]);

    echo "</p></td>n";

    } else {

    dootherstuff
    }

    }



    ------------------
    SR -
    webshiju.com
    www.jobxyz.com-IT Career Portal
    ezipindia.com--WebStudio


    "The fear of the LORD is the beginning of knowledge..."

Similar Threads

  1. Replies: 1
    Last Post: February 5th, 2004, 01:44 AM
  2. Question about the WHERE statement
    By layz d in forum MS SQL Development
    Replies: 5
    Last Post: January 28th, 2004, 12:58 PM
  3. A mixed foreach loop
    By Datamike in forum Dev Shed Lounge
    Replies: 11
    Last Post: December 17th, 2003, 09:40 PM
  4. do/while loop sTrAnGe behavior?
    By Scoobiez in forum C Programming
    Replies: 4
    Last Post: December 1st, 2003, 10:35 PM
  5. Update database/count statement
    By Signuml99 in forum Database Management
    Replies: 2
    Last Post: November 26th, 2003, 02:07 PM

IMN logo majestic logo threadwatch logo seochat tools logo