$val ) {
// if( substr( $key, -3 ) == "_id" )
if ( $key == $table_id ) {
$id[$key]= $val;
} else {
$data[$key]= $val;
}
}
foreach( $id as $key => $val )
$arr2[$key]= $val;
foreach( $data as $key => $val )
$arr2[$key]= $val;
$as_array[]= $arr2;
}
$totalrows= count( $as_array );
// if array has no rows display msg
if( $totalrows == 0 )
return "Nothing to display";
// set key and break up data struct
$newkey= $page - 1;
$newarray= array_chunk( $as_array, $limit );
// start table output
$echo.= "
\n";
// if there is a caption add it to table
if( $caption )
$echo.= "
$caption
\n";
$echo.= "
";
// go through keys of one array row for table headers
foreach( $newarray[$newkey][0] as $key => $val ) {
// if( substr( $key, -3 ) != "_id" )
if ( $key != $table_id && $key != 'peer_id' )
$echo.= "
". ucfirst( $key ) ."
";
}
if( $other_func == 'slivers' )
$echo.= "
Slivers
";
$echo.= "
\n";
// go through array row by row to output table rows
foreach( $newarray[$newkey] as $assoc ) {
$extraclass="";
if ($assoc['peer_id']) {
$extraclass="plc-foreign";
}
$echo.= "
";
foreach( $assoc as $key => $val ) {
// do not rely on keys order
$id = $assoc[$table_id];
// if( substr( $key, -3 ) == "_id" )
if ($key == $table_id) {
// $id= $val;
continue;
} elseif( $key == $main_field ) {
$echo.= "