Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Help with $row

  1. #1
    New Coder
    Join Date
    Jan 2007
    Posts
    42
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Help with $row

    Hi,
    here i am again asking for help lol. In my code i have 3 lines as shown below, i am almost sure i shouldn't have it the way it is. So my question is what is the right way of doing this? sorry guys for all the questions, as you can see i'm still learning. thanks.
    PHP Code:
    if ($row mysql_fetch_array($result)){
    if (
    $row["actnum"] == "0"){
    if (
    $row["numloginfail"] <= 5){

    Should it be like this?
    if (
    $row mysql_fetch_array($result)){
    }
    if (
    $row["actnum"] == "0"){
    //Code here
    }
    if (
    $row["numloginfail"] <= 5){
    //Code here


  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,378
    Thanks
    8
    Thanked 1,075 Times in 1,066 Posts
    PHP Code:

    foreach(mysql_fetch_array($result) as $row){

    if (
    $row["actnum"] == "0"){ 
    //Code here 

    if (
    $row["numloginfail"] <= 5){ 
    //Code here 
    }  

    }
    // end foreach 

  • Users who have thanked mlseim for this post:

    ycpc55 (07-28-2012)

  • #3
    New Coder
    Join Date
    Jan 2007
    Posts
    42
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Again thanks mlseim

    Also, anyone know if this is wise to do? thanks..
    PHP Code:
    From this:
    if (
    $row["actnum"] == "0"){ 
    //Code here 

    if (
    $row["numloginfail"] <= 5){ 
    //Code here 
    }  
    To this:
    if (
    $row["actnum"] == "0" || $row["numloginfail"] <= 5){
    //Code here 


  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    That depends on what //code here represents.
    The difference is that the first block allows 2x possible modifications on the branch conditions, while the second block allows only 1x. So it depends on if it makes sense to perform an action based on actnum and numloginfail separately, or only if it makes sense to perform an operation if either match.

  • Users who have thanked Fou-Lu for this post:

    ycpc55 (07-28-2012)


  •  

    Posting Permissions

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