Ver Mensaje Individual
  #12 (permalink)  
Antiguo 01/11/2018, 08:03
quico5
 
Fecha de Ingreso: enero-2008
Mensajes: 580
Antigüedad: 16 años, 4 meses
Puntos: 9
Respuesta: array_intersect() no funciona en un if

Resuelto al fin, gracias por las sujerencias

Código PHP:
<?php
    $cols
=['*','id_socio,socio,apellidos,edad,colegio,teléfono'][0];

    if (isset(
$args[1]))
        if (
strpos($_SERVER['QUERY_STRING'],'edad')){
            if (
$args[1]=='asc'$query="SELECT $cols FROM $cont ORDER BY $args[0] ASC";
            if (
$args[1]=='desc'$query="SELECT $cols FROM $cont ORDER BY $args[0] DESC";
        }else{
            if (
$args[1]=='desc'$query="SELECT $cols FROM $cont ORDER BY $args[0] ASC";
            if (
$args[1]=='asc'$query="SELECT $cols FROM $cont ORDER BY $args[0] DESC";
        }
    else 
$query="SELECT $cols FROM $cont";
?>

<table class="table table-striped table-dark">
    <thead class="">
        <?php foreach (mysqli_query($cnx,"SELECT $cols FROM $cont LIMIT 1") as $table): ?>
            <tr>
                <?php foreach (array_keys($table) as $key): ?>
                    <?php if (in_array($key,['socio','apellidos'])||0): ?>
                        <th>
                            <a href="<?= S.$cont.S.$metd.S.$value.S.(isset($args[1])&&$args[1]=='desc'?'asc':'desc'?>">
                                <?php strncmp($key,'id_',3)&&print(str_replace(['_','Socio'],[' ','Nombre'],ucfirst($key))) ?>
                            </a>
                        </th>
                    <?php endif ?>
                <?php endforeach ?>
            </tr>
        <?php endforeach ?>
    </thead>
    <tbody>
        <?php foreach (mysqli_query($cnx,$query) as $table): ?>
            <tr>
                <?php foreach ($table as $key => $value): ?>
                    <?php if (in_array($key,['socio','apellidos'])): ?>
                        <td>
                            <a href="<?= S.$cont.S.'ver'.S.str_replace(' ','_',$table['socio'].S.$table['apellidos']) ?>">
                                <?php if ($key=='edad'): ?>
                                    <?=date_diff(date_create($value),date_create(date('Y-m-d')))->format('%y')?>
                                <?php else: ?>
                                    <?=$value?>
                                <?php endif ?>
                            </a>
                        </td>
                     <?php endif ?>
                <?php endforeach ?>
            </tr>
        <?php endforeach ?>
        <tr></tr>
    </tbody>
</table>:-)