Joak Posted February 24, 2014 Share Posted February 24, 2014 (edited) Hello guys. I execute a query and then put the records into array, the query has ORDER BY .... why I don't have the same order in the array?, If I execute the query, the record one it's no the same that $arreglo[0]. $stmt = $this->db->prepare('SELECT a.id_torneo, b.tor_nombre, a.id_jornada, a.id_juego, a.cal_fecha_hora, id_arbitro, a.cal_estatus, a.cal_default, c.id_equipo, d.equ_nombre, c.enc_locvis, e.id_jugador, e.jug_nombre_pila, e.jug_apellido_pat, e.jug_apellido_mat, e.jug_representante, e.jug_numero, jug_fechimp_reg FROM calendario a, torneo b, encuentro c, equipo d, jugador e WHERE a.id_cliente =? AND a.id_sucursal = ? AND date(a. cal_fecha_hora)= date(?) AND a.id_cliente = b.id_cliente AND a.id_sucursal = b.id_sucursal AND a.id_torneo = b.id_torneo AND a.id_cliente = c.id_cliente AND a.id_sucursal = c.id_sucursal AND a.id_torneo = c.id_torneo AND a.id_jornada = c.id_jornada AND a.id_juego = c.id_juego AND a.id_cliente = d.id_cliente AND c.id_sucursal = d.id_sucursal AND c.id_torneo = d.id_torneo AND c.id_equipo = d.id_equipo AND d.id_cliente = e.id_cliente AND d.id_sucursal = e.id_sucursal AND d.id_torneo = e.id_torneo AND d.id_equipo = e.id_equipo AND e.jug_estatus = "A" ORDER BY 5,11') or die(mysqli_error($this->db)); $stmt->bind_param("iis", $cliente, $sucursal, $fecha); $stmt->execute(); $stmt->bind_result($id_torneo, $tor_nombre, $id_jornada, $id_juego, $fecha_partido, $id_arbitro, $cal_estatus, $cal_default, $id_equipo, $equipo_nombre, $locvis, $id_jugador, $jug_nombre, $jug_apellidop, $jug_apellidom, $jug_rep, $jug_playera, $jug_fechareg); $arreglo = array() ; $contador = 0; while ($stmt->fetch()) { $arreglo[$contador] = array("id_torneo"=>$id_torneo,"torneo_nombre"=>$tor_nombre,"id_jornada"=>$id_jornada,"id_juego"=>$id_juego,"fecha_partido"=>$fecha_partido,"id_arbitro"=>$id_arbitro,"cal_estatus"=>$cal_estatus,"cal_default"=>$cal_default,"id_equipo"=>$id_equipo,"equipo_nombre"=>$equipo_nombre,"locvis"=>$locvis,"id_jugador"=>$id_jugador,"jug_nombre"=>$jug_nombre,"jug_apellidop"=>$jug_apellidop,"jug_apellidom"=>$jug_apellidom,"jug_rep"=>$jug_rep,"jug_player"=>$jug_playera,"jug_fechareg"=>$jug_fechareg); $contador++; } Edited February 24, 2014 by Zane Quote Link to comment Share on other sites More sharing options...
.josh Posted February 24, 2014 Share Posted February 24, 2014 At face value I don't see anything wrong with this code. What have you done to know it's not the same? Quote Link to comment Share on other sites More sharing options...
ginerjm Posted February 24, 2014 Share Posted February 24, 2014 How do you know the first result is not in the first array element? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.