Jump to content


Photo

problema con variable que se le asigna al boton de menu <a href="index.php?id"


  • Please log in to reply
2 replies to this topic

#1 jdorado

jdorado

    Newbie

  • Miembros
  • Pip
  • 7 posts

Posted 06 April 2013 - 11:55 AM

este error le asigno en la codificacion l variable..pero en el navegador me sale que no esta asignada...porfavor me podrian ayudar con esto...

hay te dejo el codigo

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


$re=$_GET["id"];

$res=mysql_query("
select
foto,
texto
from
header
join
contenido
on
header.id_menu=$re
and
contenido.id_menu=$re
",$con);


?>

<html>
<head>
<title>

</title>

<style type="text/css">

body{margin-top:20px;margin-left:250px ;margin-right:200px; margin-botton:20px}
#principal{width:800 ; height:700; float:left;border:solid}
#header{width:800px; height:100px; float:left}
#main{width:800px; height:600px ;float:left}
#menu{width:180px; height:600px; float:left;background-color:#cfcfcf}
.botones{width:100px;height:25px;float:left;background-color:#666666}
.url{color:#FFFFFF;text-decoration:none}
#contenido{width:620px; height:600px;float:left;background-color:#cfcfff}



</style>
</head>

<body>
<div id="principal">
  <div id="header">
  <img src="ima/header_1.jpg" ; width:800 ;height:100>


  <div>
<div id="main" >
  <div id="menu" >
   
<?php
 
$sql=mysql_query("select * from menu",$con);

while($row=mysql_fetch_array($sql))

?>

    <br>
    <br>
   
        <div class="botones" align="center">

<a class="url" href="index.php?id=<?=$row["id_menu"];?>">  

<?php  echo $row["texto"] ;?>
</a>
     
</div>

 
 
<?php
}

?>



  </div>
 
  <div align="center" id="contenido" >
    Contenido
  </div>
 

</div>
</div>
</body>
</html>


en el mozilla me sale este mensaje......



delphi
  1. SCREAM: supresión Error ignorado por
  2. (!) Notice: Undefined index: id in C: \ wamp \ www \ Curso \ video10 \ index.php on line 5
  3. Pila de llamadas
  4. # Tiempo Memoria Función Ubicación
  5. 1 0,0008 142816 {Main} () .. \ Index.php : 0


  • 0

#2 porfi.dev

porfi.dev

    Advanced Member

  • Miembros
  • PipPipPip
  • 183 posts
  • LocationMy House @ México

Posted 08 April 2013 - 10:41 AM

es un problema... no tan problema, cada vez que ocupes una variable que no definiste antes te mandara ese error, puedes deshabilitar los errores o hacer buenas practicas.

en vez de:

$re=$_GET["id"];


utiliza:

if(isset($_GET)){
    $re=$_GET["id"];
}


  • 0

#3 luisgutierrezb

luisgutierrezb

    Advanced Member

  • Miembros
  • PipPipPip
  • 92 posts
  • LocationMéxico

Posted 08 April 2013 - 12:55 PM

Tambien en esta linea:


<a class="url" href="index.php?id=<?=$row["id_menu"];?>">


te falta un echo, para que en si lo muestre en esta página

Saludos
  • 0




IP.Board spam blocked by CleanTalk.