Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/04/2011, 16:35
rfrancomahecha
 
Fecha de Ingreso: abril-2011
Mensajes: 2
Antigüedad: 13 años
Puntos: 0
Exclamación Concatenacion y arrays

Hola a todos
Basado en este codigo:

<?php
$conexion = mysql_connect("localhost", "root", "");
mysql_select_db("cloud_prueba", $conexion);
$queEmp = "SELECT * FROM pregunta LEFT JOIN respuesta ON ID_PREGUNTA=ID_RESPUESTA WHERE TIPO_SERVICIO_PREG=1 OR TIPO_SERVICIO_PREG=4 OR TIPO_SERVICIO_PREG=12 OR TIPO_SERVICIO_PREG=94;";
mysql_query("SET NAMES 'utf8'");
$resEmp = mysql_query($queEmp, $conexion) or die(mysql_error());
$totEmp = mysql_num_rows($resEmp);

if ($totEmp> 0) {
while ($rowEmp = mysql_fetch_assoc($resEmp)) {
echo "<br>".$rowEmp['TEXTO_PREG'];
echo "<br>".$rowEmp['OPCION_1'];
}
}
mysql_close($conexion) ;
?>

Si realizo esta variaciòn no funciona:

<?php
$conexion = mysql_connect("localhost", "root", "");
mysql_select_db("cloud_prueba", $conexion);
$queEmp = "SELECT * FROM pregunta LEFT JOIN respuesta ON ID_PREGUNTA=ID_RESPUESTA WHERE TIPO_SERVICIO_PREG=1 OR TIPO_SERVICIO_PREG=4 OR TIPO_SERVICIO_PREG=12 OR TIPO_SERVICIO_PREG=94;";
mysql_query("SET NAMES 'utf8'");
$resEmp = mysql_query($queEmp, $conexion) or die(mysql_error());
$totEmp = mysql_num_rows($resEmp);

if ($totEmp> 0) {
while ($rowEmp = mysql_fetch_assoc($resEmp)) {
echo "<br>".$rowEmp['TEXTO_PREG'];
$i=1;
$string="'OPCION_$i'";
echo "<br>".$rowEmp[$string];

}
}
mysql_close($conexion) ;
?>

Por favor ayudenme, de verdad es urgente!!!

Gracias
Ricardo Franco M.