Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/01/2016, 08:18
gop92
 
Fecha de Ingreso: noviembre-2012
Mensajes: 13
Antigüedad: 11 años, 6 meses
Puntos: 0
Como ordenar una variable de mayor a menor?

Hola, que tal?, estoy intentando que la lista se ordene de mayor a menor (pago), y en caso que se repita el numero de la variable, se ordene por la id menor.
Me gustaría que alguien me pueda dar una mano.
Aqui les dejo el codigo.


Código PHP:
<?php

/*
* The MIT License
*
* Copyright 2015 nahuel.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

include_once './config.php';


$tipo filter_input(INPUT_GET"id");

if (
preg_match("/[0-9]/"$tipo) && strlen($tipo) <= 2) {

$sql_minimo "SELECT min(`id`) FROM `" $prefix "faucet` WHERE `status` = '1';";
$min $mysqli->query($sql_minimo);
$dataMin $min->fetch_assoc()['min(`id`)'];

if (
$tipo $dataMin) {
$tipo $dataMin;
}

$sql_cantidad_faucetbox "SELECT * FROM `" $prefix "faucet` WHERE `id` = '" $tipo "' AND `status` = '1';";
$config $mysqli->query($sql_cantidad_faucetbox);
$data $config->fetch_assoc();

$sql_ant "SELECT max(`id`) FROM `" $prefix "faucet` WHERE `id` < " $tipo " AND `status` = 1;";
$sql_sig "SELECT min(`id`) FROM `" $prefix "faucet` WHERE `id` > " $tipo " AND `status` = 1;";

$idSig $mysqli->query($sql_sig)->fetch_assoc()['min(`id`)'];

$idAnt $mysqli->query($sql_ant)->fetch_assoc()['max(`id`)'];
if (
$idAnt == NULL) {
$idAnt $dataMin;
}


$layout = new Template("../style/template/sitios/carga.tpl");

switch (
$data['tipo']) {
case 
2: {
$s_pago "Xapo";
}
case 
3: {
$s_pago "ePay";
}
default : {
$s_pago "Faucetbox";
}
}

$layout->set("site_title"$data['nombre']);
$layout->set("ubic"$data['ubic']);

$layout->set("color"$data['color']);
$layout->set("referer"$data['url_r']);


if (
$data['ad1'] == $data['ad2'] && $data['ad2'] == $data['ad3'] && $data['ad3'] == "") {
$layout->set("ancho"0);
} else {
$layout->set("ancho"$data['ancho']);
}



$layout->set("url"$data['url'] . $data['url_r']);

$layout->set("title"$title);
$layout->set("pago"$data['pago']);
$layout->set("tiempo"$data['tiempo']);

$layout->set("s_pago"$s_pago);
$layout->set("total_faucetbox"0);
$layout->set("ant_faucet""../include/cargaFaucet.php?id=" $idAnt);

$layout->set("home""../");
$layout->set("next""../include/cargaFaucet.php?id=" $idSig);
$layout->set("address"$cartera);

$layout->set("ad1"html_entity_decode($data['ad1']));
$layout->set("ad2"html_entity_decode($data['ad2']));
$layout->set("ad3"html_entity_decode($data['ad3']));

echo 
$layout->output();
}