Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/02/2014, 14:51
itzriper
 
Fecha de Ingreso: abril-2012
Mensajes: 9
Antigüedad: 12 años
Puntos: 0
Pregunta Consulta Inner Join con Php y mysql

hola amigos necesito hacer una consulta de 2 tablas pero cuando ejecuto este codigo me marca error

Undefined index: id in C:\wamp\www\filtro\ajax.php on line 35
Undefined index: estado in C:\wamp\www\filtro\ajax.php on line 36
Undefined index: fecha in C:\wamp\www\filtro\ajax.php on line 37

nose como puedo resolver este error gracias



<?php
include("conexion.php");

if($_GET['action'] == 'listar')
{
// valores recibidos por POST

$vpais = $_POST['estado'];
$vdel = ($_POST['del'] != '' ) ? explode("/",$_POST['del']) : '';
$val = ($_POST['al'] != '' ) ? explode("/",$_POST['al']) : '';

$sql = "SELECT orden.id AS Orden, fecha AS Fecha, CONCAT_WS( ' ', paciente.nombre, paciente.apellidos ) AS Paciente, estado AS Estado
FROM orden
INNER JOIN paciente ON paciente.dni = orden.dni
LIMIT 0 , 30 ";

// Vericamos si hay algun filtro

$sql .= ($vdel && $val) ? " where fecha BETWEEN '$vdel[2]-$vdel[1]-$vdel[0]'
AND '$val[2]-$val[1]-$val[0]' " : "";

// Ordenar por
$vorder = $_POST['estado'];

if($vorder != ''){
$sql .= " ORDER BY ".$vorder;
}

$query = mysql_query($sql);
$datos = array();

while($row = mysql_fetch_array($query))
{
$datos[] = array(
'id' => $row['id'],
'estado' => $row['estado'],
'fecha' => $row['fecha']

);
}
// convertimos el array de datos a formato json
echo json_encode($datos);
}

?>