Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/01/2015, 09:53
aldhemar
 
Fecha de Ingreso: enero-2015
Mensajes: 9
Antigüedad: 9 años, 3 meses
Puntos: 0
Exclamación Error Resource id #7 - mysql php

Estimados soy nuevo en el foro, y siempre acudo a el

quisiera que me ayudéis con lo siguiente:

tengo la siguiente consulta hecha en php

Cita:
$id_usuario = $_POST['id_usuario_combo'];
$query_nombre = ("select e.nombre from abril_empleados e inner join abril_movilidades m on $id_usuario = e.id_usuario");
$nombre = mysql_query($query_nombre);
donde $id_usuario toma valor seleccionado de un <option value>

Cita:
<select required name="id_usuario_combo">
<option value=""></option>
<?php while($row=mysql_fetch_array($resultado_empleados) )
{?>
<option value="<?php echo $row['id_usuario']?>">
<?php
echo htmlentities($row['apellido_paterno']);
echo "&nbsp;";
echo htmlentities($row['apellido_materno']);
echo "&nbsp;";
echo htmlentities($row['nombre']);
echo "&nbsp;";
echo " - ";
echo htmlentities($row['dni']);
?>
</option>
<?php } ?>
</select>

el resultado de la consulta como verán se almacena en la variable $nombre

pero al imprimir este con el echo

Cita:
<td><?php echo "Usuario: $nombre" ?></td>
en la pantalla me devuelve lo siguiente:

Cita:
Usuario: Resource id #7

ayuda!!!!!!


codigo completo
Cita:
<?php
session_start();
if(empty($_SESSION['login']))
{
header('Location: index.php');
}
?>

<?php
include ('clases/conexion.php');
//procedimiento para llenar combo
$empleados=htmlentities($_REQUEST['empleados']);
$query_empleados = ("select * from abril_empleados where planilla = 1 order by apellido_paterno asc ;");
$resultado_empleados = mysql_query($query_empleados);
?>

<html>
<head><title>ABRIL | Intranet</title>
<style type="text/css">
table
{
border-collapse: collapse;
}
</style>

</head>
<body>

<form method="post" name="movilidades_reporte" action="">
<td width="437" align="char">

<table width="774" height="146" align="center" bgcolor="#FFFFFF" border="1">
<tr><td width="238" height="26">Fecha Inicio</td><td width="514"><input required type="date" name="fecha_reporte_movilidad_inicio" value="<?php echo date("Y-m-d")?>"/></td></tr>
<tr><td width="238" height="26">Fecha Fin</td><td width="514"><input required type="date" name="fecha_reporte_movilidad_fin" value="<?php echo date("Y-m-d")?>"/></td></tr>
<tr>
<td height="26">Selecciona Usuario</td>
<td>
<!--llenando el combo con una consulta mysql -->
<select required name="id_usuario_combo">
<option value=""></option>
<?php while($row=mysql_fetch_array($resultado_empleados) )
{?>
<option value="<?php echo $row['id_usuario']?>">
<?php
echo htmlentities($row['apellido_paterno']);
echo "&nbsp;";
echo htmlentities($row['apellido_materno']);
echo "&nbsp;";
echo htmlentities($row['nombre']);
echo "&nbsp;";
echo " - ";
echo htmlentities($row['dni']);
?>
</option>
<?php } ?>
</select>
<!-- fin llenando el combo con una consulta mysql -->
</td>
</tr>



<tr>
<td height="26" colspan="2" bgcolor="#0066CC">
<!-- codigo consulta -->
<?php
include("clases/conexion.php");
$id_usuario = $_POST['id_usuario_combo'];
//
$fecha_consulta_inicio = $_POST['fecha_reporte_movilidad_inicio'];
$fecha_consulta_fin = $_POST['fecha_reporte_movilidad_fin'];
$query_consulta = ("select * from abril_movilidades where fecha between '$fecha_consulta_inicio' and '$fecha_consulta_fin' and id_usuario = '$id_usuario' order by fecha desc");
// consulta para mostrar nombre del empleado
$query_nombre = ("select e.nombre from abril_empleados e inner join abril_movilidades m on $id_usuario = e.id_usuario");
$nombre = mysql_query($query_nombre);
//
$suma = 0;
$result = mysql_query($query_consulta);
echo "<table border='1' bgcolor='FFFFFF'>";
echo "<tr>";
echo "<th width='80' align='center'>Fecha</th>";
echo "<th width='400'>Motivo</th>";
echo "<th width='200'>Origen - Destino</th>";
echo "<th width='80'>Importe</th>";
echo "<th width='150'>Firma</th>";
echo "</tr>";
while ($row = mysql_fetch_row($result))
{
echo "<tr>";
echo "<td width='80' align='center'>$row[1]</td>";
echo "<td align=center>$row[3]</td>";
echo "<td>$row[4]</td>";
echo "<td align='right'>S/$row[5]</td>";
echo "<td></td>";
echo "</tr>";
$suma =$suma+$row[5];
}
echo "</table>";


?>
<!-- fin codigo consulta -->

</tr>
<tr>
<td><?php echo "Usuario: $nombre" ?></td>
<td style="font-family:'Arial Black', Gadget, sans-serif"><?php echo "El Importe Total es: S/ $suma" ?></td>
</tr>
<tr>
<td><?php echo "Razon Social: "?></td>
<td>Limite m&aacute;ximo por d&iacute;a: S/.30</td>
</tr>
<tr>
<td><?php echo "RUC: "?></td>
<td><?php echo "Monto Reparable: "?></td>
</tr>

<tr>
<td height="28" align="center" colspan="2">
<input type="submit" value="generar" name="Reporte">&nbsp;
<input type='button' onclick='window.print();' value='Imprimir' /></td>

</tr>
</table>
</form>
</body>
</html>

Última edición por aldhemar; 28/01/2015 a las 10:09