Foros del Web » Programando para Internet » Javascript »

Pop-up con consulta php

Estas en el tema de Pop-up con consulta php en el foro de Javascript en Foros del Web. Buenas tengo el siguiente javascript Código PHP: < SCRIPT LANGUAGE = "JavaScript" > <!--  function  popUp ( URL ) { day  = new  Date (); id  =  day ...
  #1 (permalink)  
Antiguo 28/08/2008, 13:22
 
Fecha de Ingreso: agosto-2006
Mensajes: 173
Antigüedad: 17 años, 9 meses
Puntos: 1
Pop-up con consulta php

Buenas tengo el siguiente javascript

Código PHP:
<SCRIPT LANGUAGE="JavaScript">

<!-- 
function 
popUp(URL) {
day = new Date();
id day.getTime();
eval(
"page" id " = window.open(URL, '" id "', 'toolbar=0,scrollbars=2,location=0,statusbar=0,menubar=0,resizable=0,width=630,height=240');");
}
// -->
</script> 
Dentro del body, tengo lo siguiente

Código PHP:
<a href="javascript:popUp('frecuencias/<?php echo $row_Recordset1['canal2']; ?>.html')" class="menu"><?php echo $row_Recordset1['canal2']; ?></a>
Con esto consigo, que al clicar sobre el, se me abra una ventana que me lleva a otra pagina html con datos sobre frecuencias de canales de satelite.

Pero mi idea es, que utilizando este javascript haga una consulta a la base de datos donde el filtro sea
Código PHP:
<?php echo $row_Recordset1['canal2']; ?>
Hasta la fecha lo tengo así

http://www.deporte-tv.es

Pero claro los canales con sus frecuencias los creo a mano, y lo ideal es hacerlos con base de datos.

He intentado hacer un query a la db con el filtro que os comento, y hacer despues un echo con una tabla que muestre el contenido, pero no lo consigo en la pagina me muestra debajo del canal una tabla.

Mi idea es que dentro de

Código PHP:
<a href="javascript:popUp('xxxxxxxx')" class="menu"><?php echo $row_Recordset1['canal2']; ?></a>
Tendria que sustituir las XXXXX por una consulta a la base de datos con el filtro $row_Recordset1['canal2'], pero no lo consigo

Alguien me puede iluminar, muchas gracias por vuestra respuesta
  #2 (permalink)  
Antiguo 28/08/2008, 23:32
 
Fecha de Ingreso: julio-2008
Mensajes: 91
Antigüedad: 15 años, 11 meses
Puntos: 6
Respuesta: Pop-up con consulta php

Hola, haber si intentas lo siguiente>

En lugar de poner>

Código HTML:
<a href="javascript:popUp('frecuencias/<?php echo $row_Recordset1['canal2']; ?>.html')" class="menu"><?php echo $row_Recordset1['canal2']; ?></a> 
cambia la extension de html a php y le agregas un parametro:

javascript:popUp('frecuencias/<?php echo $row_Recordset1['canal2']; ?>.php?parametro=<?php echo $row_Recordset1['canal2']; ?>'

Cambias parametro pon lo que quieras. Cosa que en la pagina php lo recibes con $_GET, algo asi:

Código PHP:
$criterio=$_GET['parametro']:
$sql=mysql_query("select * from tabla where campo='$criterio'"); 

Espero te sirva de ayuda...

SAludos
  #3 (permalink)  
Antiguo 29/08/2008, 01:51
 
Fecha de Ingreso: agosto-2006
Mensajes: 173
Antigüedad: 17 años, 9 meses
Puntos: 1
Respuesta: Pop-up con consulta php

Muchas gracias raul.

He conseguido segun tus apuntes, crear el parametro, cuando situo el cursor encima del canal, este me marca el parametro con el nombre de dicho canal.

La pagina donde va la consulta y la muestra, me sale siempre vacia, como si no hiciese la consulta a la base de datos, es decir me sale la tabla pero sin los resultados deseados, pues sale vacia, este es el codigo entero de la pagina a la que va dirigido el pop-up.

Creo que el $criterio=$_GET['parametro']; no lo estoy haciendo bien, alguien me podría indicar donde cometo el error

Código PHP:
<?php
$colname_Recordset1 
"-1";
if (isset(
$_GET['parametro'])) {
  
$colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['parametro'] : addslashes($_GET['parametro']);
}
$criterio=$_GET['parametro'];
$maxRows_Recordset1 20;
$pageNum_Recordset1 0;
if (isset(
$_GET['pageNum_Recordset1'])) {
  
$pageNum_Recordset1 $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 $pageNum_Recordset1 $maxRows_Recordset1;

mysql_select_db($database_conexion1$conexion1);
$query_Recordset1 "SELECT * FROM canales WHERE name = '$criterio' ORDER BY pos DESC";
$query_limit_Recordset1 sprintf("%s LIMIT %d, %d"$query_Recordset1$startRow_Recordset1$maxRows_Recordset1);
$Recordset1 mysql_query($query_limit_Recordset1$conexion1) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);

if (isset(
$_GET['totalRows_Recordset1'])) {
  
$totalRows_Recordset1 $_GET['totalRows_Recordset1'];
} else {
  
$all_Recordset1 mysql_query($query_Recordset1);
  
$totalRows_Recordset1 mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<style type="text/css">
<!--
.Estilo1 {
    font-family: Tahoma;
    font-size: 16px;
    color: #FFFFFF;
    font-weight: bold;
}
.Estilo2 {font-family: Tahoma}
.Estilo4 {font-size: 12px}
.Estilo5 {color: #000099}
.Estilo8 {font-size: 12px; font-family: Tahoma; color: #000000; font-weight: bold; }
-->
</style>
</head>

<body>
<table width="500" border="0">
  <tr>
    <td colspan="6" bgcolor="#000099"><span class="Estilo1"><?php echo $row_Recordset1['name']; ?></span></td>
  </tr>
  <tr>
    <td width="13%" bgcolor="#E2E2E2"><div align="center" class="Estilo5 Estilo4 Estilo2"><strong>POS</strong></div></td>
    <td width="21%" bgcolor="#E2E2E2"><div align="center" class="Estilo5 Estilo4 Estilo2"><strong>Satelite</strong></div></td>
    <td width="12%" bgcolor="#E2E2E2"><div align="center" class="Estilo5 Estilo4 Estilo2"><strong>FR</strong></div></td>
    <td width="13%" bgcolor="#E2E2E2"><div align="center" class="Estilo5 Estilo4 Estilo2"><strong>SR</strong></div></td>
    <td width="13%" bgcolor="#E2E2E2"><div align="center" class="Estilo5 Estilo4 Estilo2"><strong>POL</strong></div></td>
    <td width="28%" bgcolor="#E2E2E2"><div align="center" class="Estilo5 Estilo4 Estilo2"><strong>Encriptaci&oacute;n</strong></div></td>
  </tr><?php do { ?>
  <tr>
    <td bgcolor="#E2E2E2"><div align="center" class="Estilo8"><?php echo $row_Recordset1['pos']; ?></div></td>
    <td bgcolor="#E2E2E2"><div align="left" class="Estilo8"><?php echo $row_Recordset1['sat']; ?></div></td>
    <td bgcolor="#E2E2E2"><div align="center" class="Estilo8"><?php echo $row_Recordset1['fr']; ?></div></td>
    <td bgcolor="#E2E2E2"><div align="center" class="Estilo8"><?php echo $row_Recordset1['sb']; ?></div></td>
    <td bgcolor="#E2E2E2"><div align="center" class="Estilo8"><?php echo $row_Recordset1['po']; ?></div></td>
    <td bgcolor="#E2E2E2"><div align="left" class="Estilo8"><?php echo $row_Recordset1['en']; ?></div></td>
  </tr>
  <tr>
    <td bgcolor="#E2E2E2"><div align="center" class="Estilo8"><?php echo $row_Recordset1['pos1']; ?></div></td>
    <td bgcolor="#E2E2E2"><div align="left" class="Estilo8"><?php echo $row_Recordset1['sat1']; ?></div></td>
    <td bgcolor="#E2E2E2"><div align="center" class="Estilo8"><?php echo $row_Recordset1['fr1']; ?></div></td>
    <td bgcolor="#E2E2E2"><div align="center" class="Estilo8"><?php echo $row_Recordset1['sb1']; ?></div></td>
    <td bgcolor="#E2E2E2"><div align="center" class="Estilo8"><?php echo $row_Recordset1['po1']; ?></div></td>
    <td bgcolor="#E2E2E2"><div align="left" class="Estilo8"><?php echo $row_Recordset1['en1']; ?></div></td>
  </tr>
  <tr>
    <td bgcolor="#E2E2E2"><div align="center" class="Estilo8"><?php echo $row_Recordset1['pos2']; ?></div></td>
    <td bgcolor="#E2E2E2"><div align="left" class="Estilo8"><?php echo $row_Recordset1['sat2']; ?></div></td>
    <td bgcolor="#E2E2E2"><div align="center" class="Estilo8"><?php echo $row_Recordset1['fr2']; ?></div></td>
    <td bgcolor="#E2E2E2"><div align="center" class="Estilo8"><?php echo $row_Recordset1['sb2']; ?></div></td>
    <td bgcolor="#E2E2E2"><div align="center" class="Estilo8"><?php echo $row_Recordset1['po2']; ?></div></td>
    <td bgcolor="#E2E2E2"><div align="left" class="Estilo8"><?php echo $row_Recordset1['en2']; ?></div></td>
</tr>    <?php } while ($row_Recordset1 mysql_fetch_assoc($Recordset1)); ?>
</table>
</body>
</html>
<?php
mysql_free_result
($Recordset1);
?>
Muchas gracias por vuestra ayuda

Última edición por txino_2; 29/08/2008 a las 03:35
  #4 (permalink)  
Antiguo 29/08/2008, 03:35
 
Fecha de Ingreso: agosto-2006
Mensajes: 173
Antigüedad: 17 años, 9 meses
Puntos: 1
Respuesta: Pop-up con consulta php

Ya lo tengo, por si alguien no sabe como hacerlo lo dejo aqui

Código PHP:
<?php
$colname_Recordset1 
"-1";
if (isset(
$_GET['canal'])) {
  
$colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['canal'] : addslashes($_GET['canal']);
}
mysql_select_db($database_conexion1$conexion1);
$query_Recordset1 sprintf("SELECT * FROM canales WHERE canal = '%s' ORDER BY pos DESC"$colname_Recordset1);
$Recordset1 mysql_query($query_Recordset1$conexion1) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<style type="text/css">
<!--
.Estilo1 {
    font-family: Tahoma;
    font-size: 16px;
    color: #FFFFFF;
    font-weight: bold;
}
.Estilo2 {font-family: Tahoma}
.Estilo4 {font-size: 12px}
.Estilo5 {color: #000099}
.Estilo8 {font-size: 12px; font-family: Tahoma; color: #000000; font-weight: bold; }
-->
</style>
</head>

<body>

<table width="652" border="0">
  <tr>
    <td colspan="6" bgcolor="#000099"><span class="Estilo1"><?php echo $row_Recordset1['name']; ?></span></td>
  </tr>
  <tr>
    <td width="16%" bgcolor="#E2E2E2"><div align="center" class="Estilo5 Estilo4 Estilo2"><strong>POS</strong></div></td>
    <td width="16%" bgcolor="#E2E2E2"><div align="center" class="Estilo5 Estilo4 Estilo2"><strong>Satelite</strong></div></td>
    <td width="14%" bgcolor="#E2E2E2"><div align="center" class="Estilo5 Estilo4 Estilo2"><strong>FR</strong></div></td>
    <td width="15%" bgcolor="#E2E2E2"><div align="center" class="Estilo5 Estilo4 Estilo2"><strong>SR</strong></div></td>
    <td width="15%" bgcolor="#E2E2E2"><div align="center" class="Estilo5 Estilo4 Estilo2"><strong>POL</strong></div></td>
    <td width="24%" bgcolor="#E2E2E2"><div align="center" class="Estilo5 Estilo4 Estilo2"><strong>Encriptaci&oacute;n</strong></div></td>
  </tr><?php do { ?>
  <tr>
    <td bgcolor="#E2E2E2"><div align="center" class="Estilo8"><?php echo $row_Recordset1['pos']; ?></div></td>
    <td bgcolor="#E2E2E2"><div align="left" class="Estilo8"><?php echo $row_Recordset1['sat']; ?></div></td>
    <td bgcolor="#E2E2E2"><div align="center" class="Estilo8"><?php echo $row_Recordset1['fr']; ?></div></td>
    <td bgcolor="#E2E2E2"><div align="center" class="Estilo8"><?php echo $row_Recordset1['sb']; ?></div></td>
    <td bgcolor="#E2E2E2"><div align="center" class="Estilo8"><?php echo $row_Recordset1['po']; ?></div></td>
    <td bgcolor="#E2E2E2"><div align="left" class="Estilo8"><?php echo $row_Recordset1['en']; ?></div></td>
  </tr>    <?php } while ($row_Recordset1 mysql_fetch_assoc($Recordset1)); ?>
</table>
</body>
</html>
<?php
mysql_free_result
($Recordset1);
?>
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 18:05.