Foros del Web » Programando para Internet » PHP »

Include Dentro de una Variable

Estas en el tema de Include Dentro de una Variable en el foro de PHP en Foros del Web. este es mi codigo pero no me sale. Código PHP: <table width="400px" border="0" cellspacing="0" cellpadding="0">   <tr>     <td width="100"><div align="center" class="pest"><a href="javascript :void(0);" onclick="MM_setTextOfLayer('cat','',' <?php  echo  '$gene' ; ?> ')">Categorias</a></div></td>     <td width="100"><div align="center" class="pest"><a href="javascript :void(0);" onclick="MM_setTextOfLayer('cat','','hola soy AYUDA')">Ayuda</a></div></td>     <td width="248"><div class="fav"><a href="javascript :window.external.AddFavorite('http://www.bugaso.com','Bugaso.com - Descargas gratis');"><img src="images/star.gif" width="22" height="20" border="0" align="absmiddle"> Favoritos</a></div></td>   </tr> ...
  #1 (permalink)  
Antiguo 16/10/2008, 14:38
Avatar de webelgrillo  
Fecha de Ingreso: marzo-2008
Mensajes: 142
Antigüedad: 16 años, 1 mes
Puntos: 0
Include Dentro de una Variable

este es mi codigo pero no me sale.

Código PHP:
<table width="400px" border="0" cellspacing="0" cellpadding="0">
  <tr>

    <td width="100"><div align="center" class="pest"><a href="javascript:void(0);" onclick="MM_setTextOfLayer('cat','','<?php echo '$gene';?>')">Categorias</a></div></td>
    <td width="100"><div align="center" class="pest"><a href="javascript:void(0);" onclick="MM_setTextOfLayer('cat','','hola soy AYUDA')">Ayuda</a></div></td>
    <td width="248"><div class="fav"><a href="javascript:window.external.AddFavorite('http://www.bugaso.com','Bugaso.com - Descargas gratis');"><img src="images/star.gif" width="22" height="20" border="0" align="absmiddle"> Favoritos</a></div></td>
  </tr>
  <tr>
    <td colspan="3"><div id="cat"><?php
$gene 
= include 'generos.php'

?></div></td>
  </tr>
</table>
ayudenme
  #2 (permalink)  
Antiguo 16/10/2008, 14:43
Avatar de RollerSky  
Fecha de Ingreso: marzo-2008
Mensajes: 123
Antigüedad: 16 años
Puntos: 8
Respuesta: Include Dentro de una Variable

No te va a servir porque el te imprime es un String no una funcion.. segun tengo entendido.

eso lo podrias hacer mas facil:

Código PHP:
<table width="400px" border="0" cellspacing="0" cellpadding="0"> 
  <tr> 
<?php 
  
$gene 
'generos.php'

?> 
    <td width="100"><div align="center" class="pest"><a href="javascript:void(0);" onclick="MM_setTextOfLayer('cat','','<?php echo '$gene';?>')">Categorias</a></div></td> 
    <td width="100"><div align="center" class="pest"><a href="javascript:void(0);" onclick="MM_setTextOfLayer('cat','','hola soy AYUDA')">Ayuda</a></div></td> 
    <td width="248"><div class="fav"><a href="javascript:window.external.AddFavorite('http://www.dominio.com','midominio.com - Descargas gratis');"><img src="http://www.forosdelweb.com/images/star.gif" width="22" height="20" border="0" align="absmiddle"> Favoritos</a></div></td> 
  </tr> 
  <tr> 
    <td colspan="3"><div id="cat"><?php incluide($gene);?></div></td> 
  </tr> 
</table>
  #3 (permalink)  
Antiguo 16/10/2008, 14:57
Avatar de webelgrillo  
Fecha de Ingreso: marzo-2008
Mensajes: 142
Antigüedad: 16 años, 1 mes
Puntos: 0
Respuesta: Include Dentro de una Variable

Actualmente mi codigo esta asi pero tengo un problea que el codigo se esta mostrando en la pestaña tambien como podria solucionar esto.

Código PHP:
<table width="400px" border="0" cellspacing="0" cellpadding="0">
  <tr>
<?php
$gene 
'generos.php'

?>
    <td width="100"><div align="center" class="pest"><a href="javascript:void(0);" onclick="MM_setTextOfLayer('cat','','<?php include($gene);?>')">Categorias</a></div></td>
    <td width="100"><div align="center" class="pest"><a href="javascript:void(0);" onclick="MM_setTextOfLayer('cat','','hola soy AYUDA')">Ayuda</a></div></td>
    <td width="248"><div class="fav"><a href="javascript:window.external.AddFavorite('http://www.dominio.com','dominio.com - Descargas gratis');"><img src="images/star.gif" width="22" height="20" border="0" align="absmiddle"> Favoritos</a></div></td>
  </tr>
  <tr>
    <td colspan="3"><div id="cat"><?php include($gene);?></div></td>
  </tr>
</table>
esta tabla es un cuadro con dos pestañas si le hacen clic muestra un div debajo pero tiene error ayuda porfa.
  #4 (permalink)  
Antiguo 16/10/2008, 15:08
 
Fecha de Ingreso: abril-2008
Mensajes: 453
Antigüedad: 16 años
Puntos: 16
Respuesta: Include Dentro de una Variable

fijate que en generos.php no estas haciendo algun echo y si lo estas haciendo cambialo por return
  #5 (permalink)  
Antiguo 16/10/2008, 15:19
Avatar de webelgrillo  
Fecha de Ingreso: marzo-2008
Mensajes: 142
Antigüedad: 16 años, 1 mes
Puntos: 0
Respuesta: Include Dentro de una Variable

Les pongo todo el codigo para qe me ayuden please.

Código HTML:
<!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=utf-8" />
<title>Una Pagina de Mi Dominio</title>
<style type="text/css">
<!--
#cat {
	position:relative;
	left:0px;
	top:0px;
	width:448px;
	height:108px;
	border: 1px solid #BFC4C7;
	background-color: #E3E8EE;
	visibility: visible;
	padding-top: 2px;
	padding-left: 2px;
}
.pest {
	height: 25px;
	width: 100px;
	border: 1px solid #BFC4C7;
	background-color: #C1D3E9;
	font-family: Verdana;
	font-size: 11px;
	padding-top: 6px;
	font-weight: bold;
}
.pest a {
    color: #444;
	text-decoration: none;
}
.pest a:hover {
	color: #444;
	text-decoration: none;
}
.fav {
	float: right;
	width: 248px;
}
.fav a{
	float: right;
	font-family: Arial;
	font-size: 9px;
	text-decoration: none;
	font-weight: bold;
	color: #003300;
	padding-right: 5px;
}
.fav a:hover {
	text-decoration: underline;	
}
-->
</style>
<script type="text/javascript">
<!--
function MM_setTextOfLayer(objId,x,newText) { //v9.0
  with (document) if (getElementById && ((obj=getElementById(objId))!=null))
    with (obj) innerHTML = unescape(newText);
}
//-->
</script>
</head>

<body>

<table width="400px" border="0" cellspacing="0" cellpadding="0">
  <tr>
<?php
$gene = 'generos.php'; 

?>
    <td width="100"><div align="center" class="pest"><a href="javascript:history.go(0)" onclick="MM_setTextOfLayer('cat','','<?php include($gene);?>')">Categorias</a></div></td>
    <td width="100"><div align="center" class="pest"><a href="javascript:void(0);" onclick="MM_setTextOfLayer('cat','','hola soy AYUDA')">Ayuda</a></div></td>
    <td width="248"><div class="fav"><a href="javascript:window.external.AddFavorite('http://www.dominio.com','dominio.com - Descargas gratis');"><img src="images/star.gif" width="22" height="20" border="0" align="absmiddle"> Favoritos</a></div></td>
  </tr>
  <tr>
    <td colspan="3"><div id="cat"><?php include($gene);?></div></td>
  </tr>
</table>


</body>
</html> 
el archivo gene.php solo contiene texto y un aimagen nada mas no hay codigo php lo que no quiero es que en la pestaña Categoria tambien aparezca el include no se como solucionarlo ayudenme porfa.
  #6 (permalink)  
Antiguo 16/10/2008, 15:34
 
Fecha de Ingreso: abril-2008
Mensajes: 453
Antigüedad: 16 años
Puntos: 16
Respuesta: Include Dentro de una Variable

entonces si solamente le vas a poner texto y una imagen porque no haces lo siguiente:

en el archivo gene.php

Código PHP:
          function Texto(){
             
$text 'linea uno</br>';
             
$text .= 'linea dos</br>';
             
$text .= '<img src="adasd"/>';
             return 
$text;
     } 
y en el que tenes la tabla

Código PHP:

 <!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=utf-8" />
<title>Una Pagina de Mi Dominio</title>
<style type="text/css">
<!--
#cat {
    position:relative;
    left:0px;
    top:0px;
    width:448px;
    height:108px;
    border: 1px solid #BFC4C7;
    background-color: #E3E8EE;
    visibility: visible;
    padding-top: 2px;
    padding-left: 2px;
}
.pest {
    height: 25px;
    width: 100px;
    border: 1px solid #BFC4C7;
    background-color: #C1D3E9;
    font-family: Verdana;
    font-size: 11px;
    padding-top: 6px;
    font-weight: bold;
}
.pest a {
    color: #444;
    text-decoration: none;
}
.pest a:hover {
    color: #444;
    text-decoration: none;
}
.fav {
    float: right;
    width: 248px;
}
.fav a{
    float: right;
    font-family: Arial;
    font-size: 9px;
    text-decoration: none;
    font-weight: bold;
    color: #003300;
    padding-right: 5px;
}
.fav a:hover {
    text-decoration: underline;    
}
-->
</style>
<script type="text/javascript">
<!--
function MM_setTextOfLayer(objId,x,newText) { //v9.0
  with (document) if (getElementById && ((obj=getElementById(objId))!=null))
    with (obj) innerHTML = unescape(newText);
}
//-->
</script>
</head>

<body>

<table width="400px" border="0" cellspacing="0" cellpadding="0">
  <tr>
<?php
include 'generos.php'
$texto Texto();
?>
    <td width="100"><div align="center" class="pest"><a href="javascript:history.go(0)" onclick="MM_setTextOfLayer('cat','','<?php include($gene);?>')">Categorias</a></div></td>
    <td width="100"><div align="center" class="pest"><a href="javascript:void(0);" onclick="MM_setTextOfLayer('cat','','hola soy AYUDA')">Ayuda</a></div></td>
    <td width="248"><div class="fav"><a href="javascript:window.external.AddFavorite('http://www.dominio.com','dominio.com - Descargas gratis');"><img src="http://www.forosdelweb.com/images/star.gif" width="22" height="20" border="0" align="absmiddle"> Favoritos</a></div></td>
  </tr>
  <tr>
    <td colspan="3"><div id="cat"><?php $texto?></div></td>
  </tr>
</table>


</body>
</html>
igual si lo que queres es mandar eso nomas tendrias que utilizar una base de datos
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 20:48.