Foros del Web » Programando para Internet » PHP »

Una imagen u otra

Estas en el tema de Una imagen u otra en el foro de PHP en Foros del Web. Tengo un programa al mostrar una imagen u otra el código es el siguiente que tengo para mostrar la imagen.... ya que el conecta a ...
  #1 (permalink)  
Antiguo 04/07/2008, 07:40
 
Fecha de Ingreso: julio-2008
Mensajes: 12
Antigüedad: 15 años, 9 meses
Puntos: 0
Mostrar una opción u otra

Tengo un programa al mostrar una imagen u otra

el código es el siguiente que tengo para mostrar la imagen.... ya que el conecta a la base de datos funciona correctamente al usarse ya en otras opción.

Solo tengo fayos en esta. Si alguien me pudiera ayudar

Lo que quiero conseguir.. es que si no tienen nombre aparezca una imagen y si lo tienen aparezca una con su nombre atavez de la variable nick



Cita:
if($_COOKIE['nick']==""){
echo('<img src="http://www.miwe/img/nonik.gif">');
}else{
echo('<img src="http://www.miweb.es/imaging/avatarimage?size=s&user='.$_COOKIE['nick'].'>');}



Espero que algun me solucione el problema.
  #2 (permalink)  
Antiguo 04/07/2008, 08:08
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: Mostrar una opción u otra

saludos isralusky puedes probar con esto
Código PHP:
<?
if($_COOKIE['nick']==""){
?>
<img src="http://www.miwe/img/nonik.gif" width="medida" height="medida" border="0" />

<?
}else{
?>
<img src="http://www.miweb.es/imaging/avatarimage?size=s&user='.$_COOKIE['nick'].'>" />
<? }?>
espero t funcione...
suerte
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #3 (permalink)  
Antiguo 04/07/2008, 08:25
 
Fecha de Ingreso: julio-2008
Mensajes: 12
Antigüedad: 15 años, 9 meses
Puntos: 0
Respuesta: Mostrar una opción u otra

Gracias por la ayuda... Pero me sigue sin funcionar!!!

y en lugar de por cookie no se podría hacer directamente desde la bd?
  #4 (permalink)  
Antiguo 04/07/2008, 08:27
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: Mostrar una opción u otra

q problema t da??? a ver q podemos solucionar.. a mi ese codigo me funciona.. quizas podamos ver q pasa en tu caso
.. primero cuentame de donde viene "nick"
y pq usas cookie para llamarlo... muestranos tu codigo completo!!!
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #5 (permalink)  
Antiguo 04/07/2008, 08:34
 
Fecha de Ingreso: julio-2008
Mensajes: 12
Antigüedad: 15 años, 9 meses
Puntos: 0
Respuesta: Mostrar una opción u otra

Es el sistema de noticias de una web
donde quisiera que apareciera una imagen delante de cada comentario de usuario



Cita:
<body link="#000000" vlink="#000000" alink="#000000" style="background-image: url('http://images.habbos.es/rebound/bkg.png')">

<table height="2" cellSpacing="0" cellPadding="0" width="430" align="center">
</table>
<table height="49" cellSpacing="0" cellPadding="0" width="425" align="center">
<tr>
<td width="430" height="11">
<table height="45" cellSpacing="0" cellPadding="0" width="434" align="center">
<tr>
<td width="432" height="1" class="content_box"><?php
$noticias="on";
$limite="15";
if($_GET[comentarios]=="ver" or $_GET[comentarios]=="a&ntilde;adir"){
$limite="1";
}
include("admin/conectar_n.php");
$query=mysql_query("SELECT * FROM noticias WHERE id='$_GET[idn]' order by id desc limit $limite");
$prueba=mysql_num_rows($query);
if($prueba=="0"){
$query=mysql_query("SELECT * FROM noticias order by id desc limit $limite");
}
while($rows=mysql_fetch_array($query)){
$query_c=mysql_query("SELECT * FROM comentarios WHERE idn='$rows[id]'");
$num=mysql_num_rows($query_c);
?>
<table width="430" height="117" align="center" cellpadding="0" cellspacing="0">
<tr>
<td class="content_box" height="11">
<img src="http://www.habbos.es/images/menus/red_head.png" width="430" height="11"></img></td>
</tr>
<tr>
<td background="http://www.habbos.es/images/menus/red_middle.png" class="content" height="86"><font class="topnews_u"><?php echo"".$rows[title]."";?></font>
<?php if($rows[image]=="http://" or ""){
echo'<img src=Leer_platz_klein.gif align="right"/>';
}else{
echo'<img src='.$rows[image].' align="right"/>';
}?>
<div align="left" class="copy"><?php echo"".$rows[tema]."";?></div>
<br />
<?php echo"".$rows[notice]."";?><br />
<br />
Escrito por: <?php echo"".$rows[user]."";?><?php echo"<a href=?comentarios=anadir&idn=".$rows[id]."> Comentarios</a>";?>(<?php echo"".$num."";?>) <?php echo"<a href=?comentarios=anadir&idn=".$rows[id].">A&ntilde;adir</a>";?> </td>
</tr>
<tr>
<td>
<img src="http://www.habbos.es/images/menus/red_bottom.png" width="430" height="17" />
<br></td>
</tr>
</table>
<span class="content">
<?php
}if($_GET[comentarios]=="anadir"){
?>
</span>
<table width="432" height="117" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="430" height="11">
<img src="http://www.habbos.es/images/menus/grey_head.png" width="430" height="11" /></td>
</tr>
<tr>
<td background="http://www.habbos.es/images/menus/grey_middle.png" class="content" height="54"><table width="391" border="00" align="center" cellpadding="0" cellspacing="0" class="Stil1">
<tr>
<td width="391" height="36"><br>
<?php
while($rows_c=mysql_fetch_array($query_c)){
$query7=mysql_query("SELECT * FROM comentarios WHERE idn='$_GET[idn]'");
if(mysql_num_rows($query7)=="0"){
echo("<b>No hay comentarios aun en esta noticia, <a href=?comentarios=a&ntilde;adir&id=".$rows[id]."pon el primero!");
}else{
if($_COOKIE[nick]==".SeWe." or $_COOKIE[nick]=="chimechu" or $_COOKIE[nick]=="::vn::" or $_COOKIE[nick]=="Trambel." or $_COOKIE[nick]=="cj256" or $_COOKIE[nick]=="::lob::" or $_COOKIE[nick]==".:.uron.:." or $_COOKIE[nick]=="-:-aherre16-:-"){
echo("<a href=borrar_coment23492040587163fkfoasdunqwo123.ph p?id=".$rows_c[id].">Borrar comentario</a> IP:".$rows_c[ip]."<br>");
}
echo("<b>");

Aquí mostrar la imagen de antes


echo ereg_replace( "<", "&lt;", $rows_c[usuario] );
echo(":&nbsp;</b>");?><?php echo ereg_replace( "<", "&lt; &nbsp;" , $rows_c[comentario] );?><?php echo(" ".$rows_c[fecha]."<br><br>");}?>
<?php
}?></td>
</tr>
</table>
<table width="393" border="00" align="center" cellpadding="0" cellspacing="0" class="Stil1">
<tr>
<td width="413" height="36"><div align="center">
<form action="procesar_nuevo_comentario.php" method="post">

<input type="hidden" value=<?php echo($_SERVER[REMOTE_ADDR]);?> name="ip">
<hr>
<p align="left"><strong>Fecha:</strong>
<?php $date=date("d-m-Y");
echo"".$date."";?><br>
<strong>ID:</strong>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="idn" type="text" readonly="" class="Stil1" id="idn2"value="<?php echo "".$_GET[idn]."";?>" size="5">
<br>
<strong>Autor:</strong>
<?php
if($_COOKIE['nick']){
echo'<input readonly="" name="autor" type="text" value="'.$_COOKIE['nick'].'" class="Stil1">';
}else{
$us="invi";
echo'<input readonly="" name="autor" type="text" value="Invitad@" class="Stil1">';
}
?>
<br>
<strong>Comentario:</strong>
<input name="comentario" type="text"<?php if($us=="invi"){
echo "disabled='disabled'"; }?> class="Stil1" value="" size="50" maxlength="200">
<br></p>

<input name="Submit" <?php if($us=="invi"){
echo "disabled='disabled'"; }?>type="submit" class="Stil1" value="Enviar">
</p>
</form>
</div><br>
<center><?
if($us=="invi"){
echo("Sólo puedes publicar comentarios si estás registrado.");
}
?></center>
</td>
</tr>
</table> </tr>
<tr>
<td>
<img src="http://www.habbos.es/images/menus/grey_bottom.png" width="430" height="17" /></td>
</tr>
</table>
<?php
}?>
<p></td>
</tr>
</table>
<table height="2" cellSpacing="0" cellPadding="0" width="430" align="center">
</table> </td>
</tr>
</table></td>

</body>

donde está lo rojo tendría que ir la imagen indicada en el primer post
  #6 (permalink)  
Antiguo 05/07/2008, 03:14
 
Fecha de Ingreso: mayo-2008
Mensajes: 15
Antigüedad: 15 años, 10 meses
Puntos: 0
Respuesta: Mostrar una opción u otra

¿Podría alguien ayudar en esto?

Esque yo tengo un problema similar y me sería de gran ayuda que alguien que sepa dónde puede estar el error nos dedice unos minutillos.

Gracias.
  #7 (permalink)  
Antiguo 05/07/2008, 07:05
 
Fecha de Ingreso: julio-2008
Mensajes: 12
Antigüedad: 15 años, 9 meses
Puntos: 0
Una imagen u otra

Dentro de un sistema de noticias con comentarios.
Quisiera que al escribir un comentario saliera una imagen u otra

El código de la página es el siguiente

Cita:
<body link="#000000" vlink="#000000" alink="#000000" style="background-image: url('http://images.habbos.es/rebound/bkg.png')">

<table height="2" cellSpacing="0" cellPadding="0" width="430" align="center">
</table>
<table height="49" cellSpacing="0" cellPadding="0" width="425" align="center">
<tr>
<td width="430" height="11">
<table height="45" cellSpacing="0" cellPadding="0" width="434" align="center">
<tr>
<td width="432" height="1" class="content_box"><?php
$noticias="on";
$limite="15";
if($_GET[comentarios]=="ver" or $_GET[comentarios]=="a&ntilde;adir"){
$limite="1";
}
include("admin/conectar_n.php");
$query=mysql_query("SELECT * FROM noticias WHERE id='$_GET[idn]' order by id desc limit $limite");
$prueba=mysql_num_rows($query);
if($prueba=="0"){
$query=mysql_query("SELECT * FROM noticias order by id desc limit $limite");
}
while($rows=mysql_fetch_array($query)){
$query_c=mysql_query("SELECT * FROM comentarios WHERE idn='$rows[id]'");
$num=mysql_num_rows($query_c);
?>
<table width="430" height="117" align="center" cellpadding="0" cellspacing="0">
<tr>
<td class="content_box" height="11">
<img src="http://www.habbos.es/images/menus/red_head.png" width="430" height="11"></img></td>
</tr>
<tr>
<td background="http://www.habbos.es/images/menus/red_middle.png" class="content" height="86"><font class="topnews_u"><?php echo"".$rows[title]."";?></font>
<?php if($rows[image]=="http://" or ""){
echo'<img src=Leer_platz_klein.gif align="right"/>';
}else{
echo'<img src='.$rows[image].' align="right"/>';
}?>
<div align="left" class="copy"><?php echo"".$rows[tema]."";?></div>
<br />
<?php echo"".$rows[notice]."";?><br />
<br />
Escrito por: <?php echo"".$rows[user]."";?><?php echo"<a href=?comentarios=anadir&idn=".$rows[id]."> Comentarios</a>";?>(<?php echo"".$num."";?>) <?php echo"<a href=?comentarios=anadir&idn=".$rows[id].">A&ntilde;adir</a>";?> </td>
</tr>
<tr>
<td>
<img src="http://www.habbos.es/images/menus/red_bottom.png" width="430" height="17" />
<br></td>
</tr>
</table>
<span class="content">
<?php
}if($_GET[comentarios]=="anadir"){
?>
</span>
<table width="432" height="117" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="430" height="11">
<img src="http://www.habbos.es/images/menus/grey_head.png" width="430" height="11" /></td>
</tr>
<tr>
<td background="http://www.habbos.es/images/menus/grey_middle.png" class="content" height="54"><table width="391" border="00" align="center" cellpadding="0" cellspacing="0" class="Stil1">
<tr>
<td width="391" height="36"><br>
<?php
while($rows_c=mysql_fetch_array($query_c)){
$query7=mysql_query("SELECT * FROM comentarios WHERE idn='$_GET[idn]'");
if(mysql_num_rows($query7)=="0"){
echo("<b>No hay comentarios aun en esta noticia, <a href=?comentarios=a&ntilde;adir&id=".$rows[id]."pon el primero!");
}else{
if($_COOKIE[nick]==".SeWe." or $_COOKIE[nick]=="chimechu" or $_COOKIE[nick]=="::vn::" or $_COOKIE[nick]=="Trambel." or $_COOKIE[nick]=="cj256" or $_COOKIE[nick]=="::lob::" or $_COOKIE[nick]==".:.uron.:." or $_COOKIE[nick]=="-:-aherre16-:-"){
echo("<a href=borrar_coment23492040587163fkfoasdunqwo123.ph p?id=".$rows_c[id].">Borrar comentario</a> IP:".$rows_c[ip]."<br>");
}
echo("<b>");

Aquí mostrar la imagen


echo ereg_replace( "<", "&lt;", $rows_c[usuario] );
echo(":&nbsp;</b>");?><?php echo ereg_replace( "<", "&lt; &nbsp;" , $rows_c[comentario] );?><?php echo(" ".$rows_c[fecha]."<br><br>");}?>
<?php
}?></td>
</tr>
</table>
<table width="393" border="00" align="center" cellpadding="0" cellspacing="0" class="Stil1">
<tr>
<td width="413" height="36"><div align="center">
<form action="procesar_nuevo_comentario.php" method="post">

<input type="hidden" value=<?php echo($_SERVER[REMOTE_ADDR]);?> name="ip">
<hr>
<p align="left"><strong>Fecha:</strong>
<?php $date=date("d-m-Y");
echo"".$date."";?><br>
<strong>ID:</strong>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="idn" type="text" readonly="" class="Stil1" id="idn2"value="<?php echo "".$_GET[idn]."";?>" size="5">
<br>
<strong>Autor:</strong>
<?php
if($_COOKIE['nick']){
echo'<input readonly="" name="autor" type="text" value="'.$_COOKIE['nick'].'" class="Stil1">';
}else{
$us="invi";
echo'<input readonly="" name="autor" type="text" value="Invitad@" class="Stil1">';
}
?>
<br>
<strong>Comentario:</strong>
<input name="comentario" type="text"<?php if($us=="invi"){
echo "disabled='disabled'"; }?> class="Stil1" value="" size="50" maxlength="200">
<br></p>

<input name="Submit" <?php if($us=="invi"){
echo "disabled='disabled'"; }?>type="submit" class="Stil1" value="Enviar">
</p>
</form>
</div><br>
<center><?
if($us=="invi"){
echo("Sólo puedes publicar comentarios si estás registrado.");
}
?></center>
</td>
</tr>
</table> </tr>
<tr>
<td>
<img src="http://www.habbos.es/images/menus/grey_bottom.png" width="430" height="17" /></td>
</tr>
</table>
<?php
}?>
<p></td>
</tr>
</table>
<table height="2" cellSpacing="0" cellPadding="0" width="430" align="center">
</table> </td>
</tr>
</table></td>

</body>

Donde pone la imagen e intentado insertar este código

Cita:
if($_COOKIE['nick']==""){
echo('<img src="http://www.miwe/img/nonik.gif">');
}else{
echo('<img src="http://www.miweb.es/imaging/avatarimage?size=s&user='.$_COOKIE['nick'].'>');}
Pero simplemente me detecta la primera. Sin funcionar la otra.


Espero que me podaís ayudar
  #8 (permalink)  
Antiguo 05/07/2008, 09:03
Avatar de jaronu  
Fecha de Ingreso: febrero-2008
Mensajes: 2.183
Antigüedad: 16 años, 2 meses
Puntos: 52
Respuesta: Una imagen u otra

Hola

Intenta

Código PHP:
if($_COOKIE['nick']==NULL){
echo(
'<img src="http://www.miwe/img/nonik.gif">');
}else{
echo(
'<img src="http://www.miweb.es/imaging/avatarimage?size=s&user='.$_COOKIE['nick'].'>');} 
o usando isset para saber si esta definida la variable.

Código PHP:
if(!isset($_COOKIE['nick'])){ // si no esta definida la variable 
echo('<img src="http://www.miwe/img/nonik.gif">');
}else{
echo(
'<img src="http://www.miweb.es/imaging/avatarimage?size=s&user='.$_COOKIE['nick'].'>');} 
Un saludo
  #9 (permalink)  
Antiguo 05/07/2008, 18:45
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Una imagen u otra

Temas unidos por favor no dupliques temas.
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:25.