Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/05/2015, 17:48
robespinosa90
 
Fecha de Ingreso: enero-2015
Ubicación: Guayaquil
Mensajes: 17
Antigüedad: 9 años, 4 meses
Puntos: 0
Información Sentencia para obtener ultimo registro de bd

Tengo el sgte codigo.

Código PHP:
Ver original
  1. <?php
  2.  
  3. // array for JSON response
  4. $response = array();
  5. // include db connect class
  6. require_once __DIR__ . '/db_connect.php';
  7. // connecting to db
  8. $db = new DB_CONNECT();
  9. $sql = "SELECT COUNT(*) FROM pedido";
  10. // y obtienes su resultado
  11. $resultado = mysql_query($sql) or die(mysql_error());
  12. $total = mysql_result($resultado, 0);
  13. if ($total > 0) {
  14.     $result = mysql_query("SELECT MAX(ped_num_pedido)+1 AS id FROM pedido") or die(mysql_error());
  15. // check for empty result
  16.      $response["pedido"] = array();
  17.   while($row = mysql_fetch_row($result)) {
  18.             while ($row = mysql_fetch_array($result)) {
  19.            
  20.                 $cliente = array();
  21.                 $cliente["Pedido"] = $row[0];          
  22.                 array_push($response["pedido"], $cliente);
  23.             }
  24.             $response["success"] = 1;
  25.             $response["message"] = "Sgte Registro";
  26.  
  27.             // echoing JSON response
  28.             echo json_encode($response);
  29.         }
  30.    
  31. } else {
  32.      
  33.     $response["success"] = 0;
  34.     $response["message"] = "1er Registro";
  35.     echo json_encode($response);
  36. }
  37. ?>

Alguien que me pueda decir que tengo mal que no me arroja el valor alguno en el arreglo