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 7 of 7
  1. #1
    New Coder
    Join Date
    Jan 2012
    Location
    Latvia
    Posts
    65
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Post Hide defined data from Array..

    Hello friends! I got a small problem. I am making a dynamic table. The table is displayed according to settings defined at the start..

    UPDATED:

    I just figured out how to convert the row's data, and show only the converted version. Now I want the code to compare values from predefined ARRAY, not straight in the "IF" here:

    PHP Code:

    if($key == "lastactive") { echo "Converted1"; } 
    elseif(
    $key == "country") { echo "Converted2";  }                     
    else {echo 
    $row[$key];} 
    Here is the code:

    PHP Code:

    # TABLE ROWS

    $table_columns_array = array(

        
    'id',
        
    'name',
        
    'surname',
        
    'email',
        
    'country',
        
    'ip',
        
    'lastactive',
        
    'verified'

    );


    # UNIQUE TABLE ROWS

    $table_rows_unique = array(

        
    'lastactive' => 'date',
        
    'country' => 'flag',
    ); 
    PHP Code:

            <? while($row mysql_fetch_assoc($sql_users_all)) {?>
            <tr>
                <? foreach($row as $key => $data) {
                
                
    ?> <td align="center" style="padding:1px;"> <? 
        
                        
    foreach($table_rows_unique as $key2 => $data_type){
    /*
                                $Obj_data_convert -> data = $data;
                                $Obj_data_convert -> type = $data_type;
                                
                                echo $Obj_data_convert -> convert();
                        }
    */                        
                        
    }                
                        if(
    $key == "lastactive") { echo "Converted1"; } 
                        elseif(
    $key == "country") { echo "Converted2";  }                     
                        else {echo 
    $row[$key];}
                        

                
    ?> </td>
            <?}?> </tr>

    Update: This is a screenshot of the table returned.



    Thank you for the help..
    Last edited by WingTsun; 02-24-2012 at 02:16 AM.

  • #2
    Regular Coder stevenmw's Avatar
    Join Date
    Jun 2007
    Location
    OK
    Posts
    497
    Thanks
    27
    Thanked 31 Times in 31 Posts

  • #3
    New Coder
    Join Date
    Jan 2012
    Location
    Latvia
    Posts
    65
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Thank you for the response, But it seems you didn't understand whats the problem.

    It is not the convertation process, It is working fine in in the code. The problem is I need to hide the data returned, to now show the non-converted version too in the loop..

  • #4
    Regular Coder stevenmw's Avatar
    Join Date
    Jun 2007
    Location
    OK
    Posts
    497
    Thanks
    27
    Thanked 31 Times in 31 Posts
    Can't you just change it then?

    Why can't you just change

    PHP Code:
     echo $row[$key]; 
    To the row you want displayed?

    Or even make another variable that contains the unconverted data and use that variable instead of key?

    PHP Code:
     echo $row[$unconverteddata]; 

  • #5
    New Coder
    Join Date
    Jan 2012
    Location
    Latvia
    Posts
    65
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Well If I put a new loop to show data, defined in array in that place, It returns all row data in every table column ..

    Well you can see the base problem here on my local test server: http://62.122.21.179/WTPanel/?page=users ..
    Last edited by WingTsun; 02-24-2012 at 12:27 AM.

  • #6
    New Coder
    Join Date
    Jan 2012
    Location
    Latvia
    Posts
    65
    Thanks
    8
    Thanked 2 Times in 2 Posts
    I have added a screenshot to the original post.

  • #7
    New Coder
    Join Date
    Jan 2012
    Location
    Latvia
    Posts
    65
    Thanks
    8
    Thanked 2 Times in 2 Posts
    I just figured out how to convert the row's data, and show only the converted version. Now I want the code to compare values from predefined ARRAY, not straight in the "IF" here:

    PHP Code:
    if($key == "lastactive") { echo "Converted1"; } 
    elseif(
    $key == "country") { echo "Converted2";  }                     
    else {echo 
    $row[$key];} 
    Now I am updating the first post.


  •  

    Posting Permissions

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