...

View Full Version : Hide defined data from Array..



WingTsun
02-23-2012, 10:12 PM
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:




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



Here is the 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',
);






<? 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.

http://www.bildites.lv/images/1nulrgo72akue4203d.jpg

Thank you for the help.. ;)

stevenmw
02-23-2012, 10:34 PM
http://www.codingforums.com/showthread.php?t=246407

WingTsun
02-23-2012, 10:54 PM
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.. :)

stevenmw
02-23-2012, 11:06 PM
Can't you just change it then?

Why can't you just change



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?



echo $row[$unconverteddata];

WingTsun
02-23-2012, 11:32 PM
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 .. :)

WingTsun
02-24-2012, 12:27 AM
I have added a screenshot to the original post.

WingTsun
02-24-2012, 02:06 AM
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:



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


Now I am updating the first post.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum