Foros del Web » Programando para Internet » PHP »

variable para ver bd

Estas en el tema de variable para ver bd en el foro de PHP en Foros del Web. quiero que una variable id, muestre completamente una fila completa de esa misma id, por ejemplo si es pagina.php?id=1 de los resultados de id head, ...
  #1 (permalink)  
Antiguo 19/03/2002, 20:10
Avatar de lado2mx
Colaborador
 
Fecha de Ingreso: agosto-2001
Ubicación: Veracruz
Mensajes: 3.720
Antigüedad: 22 años, 8 meses
Puntos: 9
variable para ver bd

quiero que una variable id, muestre completamente una fila completa de esa misma id, por ejemplo

si es pagina.php?id=1

de los resultados de id
head,
enter,
total_note,
font,
date,
time.

Espero haberme explicado

<html><center><iframe src="http://www.ladodos.com/firma/firma.php" width=500 height=150></iframe></center></html>
  #2 (permalink)  
Antiguo 20/03/2002, 11:10
Avatar de Manoloweb  
Fecha de Ingreso: enero-2002
Ubicación: Monterrey
Mensajes: 2.454
Antigüedad: 22 años, 3 meses
Puntos: 5
Re: variable para ver bd

... (tu sabes conectarte)...

$resultado=mysql_query(select * from mitabla where id=$variable);
$fila=mysql_fetch_array($resultado);
$resultado= $fila['head'].&quot;,&lt;br&gt;&quot;.$fila['enter'].&quot;,&lt;br&gt;&quot;.$fila['total_note'].&quot;,&lt;br&gt;&quot;.$fila['font'].&quot;,&lt;br&gt;&quot;.$fila['date'].&quot;,&lt;br&gt;&quot;.$fila['time'].&quot;.&quot;

echo $resultado

Esto haria lo que pides LITERALMENTE, ahi le mueves para lo que buscas especificamente.

(puede que exista un metodo mas sencillo pero no me lo se )

Saludos ;)

<tr>
<td bgcolor="#339933"> <font face="Verdana, Arial" size="1" color="#FFFFFF">>>
[/CODE]</td> <td align="right" bgcolor="#666666">
  #3 (permalink)  
Antiguo 20/03/2002, 11:12
Avatar de Manoloweb  
Fecha de Ingreso: enero-2002
Ubicación: Monterrey
Mensajes: 2.454
Antigüedad: 22 años, 3 meses
Puntos: 5
Re: variable para ver bd

PERDON!!!

Le puse $resultado a las 2 variables

A la de la sentencia SQL puedes lñlamarle $result

Ahi disculparas por las prisas...

<tr>
<td bgcolor="#339933"> <font face="Verdana, Arial" size="1" color="#FFFFFF">>>
[/CODE]</td> <td align="right" bgcolor="#666666">
  #4 (permalink)  
Antiguo 20/03/2002, 11:38
Avatar de lado2mx
Colaborador
 
Fecha de Ingreso: agosto-2001
Ubicación: Veracruz
Mensajes: 3.720
Antigüedad: 22 años, 8 meses
Puntos: 9
Re: variable para ver bd

gracias manolo, esta excelente...

<html><center><iframe src="http://www.ladodos.com/firma/firma.php" width=500 height=150></iframe></center></html>
  #5 (permalink)  
Antiguo 20/03/2002, 12:23
Avatar de lado2mx
Colaborador
 
Fecha de Ingreso: agosto-2001
Ubicación: Veracruz
Mensajes: 3.720
Antigüedad: 22 años, 8 meses
Puntos: 9
Re: variable para ver bd

lo rearme con el codigo que tengo, en español y me esta dando error

Código:
       &lt;?
 $conn = mysql_connect(&quot;www.dominio.com&quot;,&quot;usuario&quot;,&quot;password&quot;);
 mysql_select_db(&quot;unico_db&quot;);
 $result = mysql_query(&quot;SELECT * FROM nota WHERE id=$variable&quot;);
 echo mysql_error();
 $fila=mysql_fetch_array($result);
 echo &quot;&quot;;
$resultado=&quot;&lt;h1&gt;&lt;font face='Tahoma'&gt;&quot;.$fila['cabeza'].&quot;&lt;/font&gt;&lt;/h1&gt;
 &lt;br&gt;&lt;font face='Arial, Helvetica, sans-serif' size=2&gt;&lt;b&gt;&quot;.$fila['entrada'].&quot;&lt;/b&gt;&lt;/font&gt;
 &lt;br&gt;&lt;/b&gt;
 &lt;br&gt;&lt;br&gt;&lt;font face='Arial, Helvetica, sans-serif' size=2 color='#FFFFFF'&gt;Fuente :&quot;.$fila['fuente'].&quot;&lt;/font&gt;
  &lt;br&gt;&lt;br&gt;&lt;font face='Arial, Helvetica, sans-serif' size=2 color='#FFFFFF'&gt;&quot;.$fila['nota_completa'].&quot;&lt;/font&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;&lt;u&gt;Ingresado el::&lt;/u&gt;&lt;/b&gt;&quot;.$fila['fecha'].&quot; | &lt;b&gt;&lt;u&gt;Hora:&lt;/u&gt;&lt;/b&gt;&quot;.$fila['hora'].&quot;&lt;/font&gt;&quot;;
  echo $resultado;

?&gt;
y el error es:

Warning: Supplied argument is not a valid MySQL result resource in /home1/l/a/d/pagina.org/htdocs/pagina/pagina.php on line 13

donde 13 es :
Código:
 
 $fila=mysql_fetch_array($result);
que paso???

<html><center><iframe src="http://www.ladodos.com/firma/firma.php" width=500 height=150></iframe></center></html>
  #6 (permalink)  
Antiguo 20/03/2002, 18:46
Avatar de lado2mx
Colaborador
 
Fecha de Ingreso: agosto-2001
Ubicación: Veracruz
Mensajes: 3.720
Antigüedad: 22 años, 8 meses
Puntos: 9
Re: variable para ver bd

nadie sabe?

<html><center><iframe src="http://www.ladodos.com/firma/firma.php" width=500 height=150></iframe></center></html>
  #7 (permalink)  
Antiguo 21/03/2002, 01:51
Avatar de Manoloweb  
Fecha de Ingreso: enero-2002
Ubicación: Monterrey
Mensajes: 2.454
Antigüedad: 22 años, 3 meses
Puntos: 5
Re: variable para ver bd

Parece que tienes un error con la sentencia SQL, probablemente te esta regresando un resultado NULO

Prueba cambiando $variable por un dato que sepas que te va a regresar al menos una fila

Espero que por ahi encuentres el error.

Saludos

<tr>
<td bgcolor="#339933"> <font face="Verdana, Arial" size="1" color="#FFFFFF">>>
[/CODE]</td> <td align="right" bgcolor="#666666">
  #8 (permalink)  
Antiguo 21/03/2002, 13:50
Avatar de lado2mx
Colaborador
 
Fecha de Ingreso: agosto-2001
Ubicación: Veracruz
Mensajes: 3.720
Antigüedad: 22 años, 8 meses
Puntos: 9
Re: variable para ver bd

me fije en este error del sql:

You have an error in your SQL syntax near 'FROM nota WHERE id=2' at line 1
Warning: Supplied argument is not a valid MySQL result resource in /home1/l/a/d/ladodos.com/htdocs/noticias/notas.php on line

donde id=2 es id=$variable

donde esta el error, que no entiendo, ayudenme

<html><center><iframe src="http://www.ladodos.com/firma/firma.php" width=500 height=150></iframe></center></html>
  #9 (permalink)  
Antiguo 21/03/2002, 21:54
Avatar de Manoloweb  
Fecha de Ingreso: enero-2002
Ubicación: Monterrey
Mensajes: 2.454
Antigüedad: 22 años, 3 meses
Puntos: 5
Re: variable para ver bd

La verdad no entoendo

Por que no me mandas una parte de tu BD en un TXT para probar?

La verdad que yo uso una sentencia IDENTICA en un script, y no he tenido tal error.

Por cierto, como te fue en la reunion? espero que muy bien!

Saludos ;)

<tr>
<td bgcolor="#339933"> <font face="Verdana, Arial" size="1" color="#FFFFFF">>>
[/CODE]</td> <td align="right" bgcolor="#666666">
  #10 (permalink)  
Antiguo 22/03/2002, 11:52
asound
Invitado
 
Mensajes: n/a
Puntos:
Re: variable para ver bd

pues yo trate de revisar el código y tampoco vi el error lo siento cris
  #11 (permalink)  
Antiguo 22/03/2002, 13:12
Avatar de lado2mx
Colaborador
 
Fecha de Ingreso: agosto-2001
Ubicación: Veracruz
Mensajes: 3.720
Antigüedad: 22 años, 8 meses
Puntos: 9
Re: variable para ver bd

Pueden ver mas del error en :

<a href='ir.asp?http://www.ladodos.com/noticias/notas.php?id=4' target='_blank'>http://www.ladodos.com/noticias/notas.ph...</a>

Con este error, es que no lo puse completo:

_
You have an error in your SQL syntax near 'FROM nota WHERE id=2' at line 1
Warning: Supplied argument is not a valid MySQL result resource in /home1/l/a/d/ladodos.com/htdocs/noticias/notas.php on line 20



<html><center><iframe src="http://www.ladodos.com/firma/firma.php" width=500 height=150></iframe></center></html>
  #12 (permalink)  
Antiguo 23/03/2002, 18:15
Avatar de Manoloweb  
Fecha de Ingreso: enero-2002
Ubicación: Monterrey
Mensajes: 2.454
Antigüedad: 22 años, 3 meses
Puntos: 5
Re: variable para ver bd


...
elseif ($que=='caracteristicas')
{
$condicion='where completo=1001';
}
else
{
$condicion='where completo=2';
}
conectar();
$casos=mysql_query(&quot;select ID,Name from evaluados $condicion order by Name&quot;);

Esta la acabo de hacer y me esta funcionando...

Al principio me marco el mismo error, pero resulta que me estaba equivocando en el nombre del campo &quot;Name&quot; (lo estaba poniendo como &quot;name&quot;)




<tr>
<td bgcolor="#339933"> <font face="Verdana, Arial" size="1" color="#FFFFFF">>>
[/CODE]</td> <td align="right" bgcolor="#666666">
  #13 (permalink)  
Antiguo 24/03/2002, 13:10
Avatar de lado2mx
Colaborador
 
Fecha de Ingreso: agosto-2001
Ubicación: Veracruz
Mensajes: 3.720
Antigüedad: 22 años, 8 meses
Puntos: 9
Re: variable para ver bd

LO RESOLVI!!!!
:) :) :) :)
Rehice el codigo, poniendo lo que tu pusiste primero, y me resulto, gracias Manolo

GO AWAY!!!!!!!!

<html><center><iframe src="http://www.ladodos.com/firma/firma.php" width=500 height=150></iframe></center></html>
  #14 (permalink)  
Antiguo 24/03/2002, 14:15
 
Fecha de Ingreso: marzo-2002
Mensajes: 30
Antigüedad: 22 años, 1 mes
Puntos: 0
Re: variable para ver bd

Ahi va otra forma... je.. namas cambias los campos y tablas a los tuyos...
Código:
  
&lt;?

$id=addslashes($id);
mysql_connect(&quot;host&quot;,&quot;usuario&quot;,&quot;db&quot;);
mysql_select_db(&quot;base&quot;);
$t = &quot;bandas&quot;;
$c=mysql_query(&quot;select * from $t where id='$id'&quot;);
$d=mysql_fetch_object($c);
if(is_object($d))
{	
	echo &quot;	

	$d-&gt;id  &lt;br&gt;
	$d-&gt;banda &lt;br&gt;
	$d-&gt;pais &lt;br&gt;
	$d-&gt;genero &lt;br&gt;

	&quot;;
			
}
else {	
	echo &quot; &lt;h1&gt;Error: No se econtró el Id &lt;/h1&gt; &quot;;
}
mysql_close();


?&gt;
  #15 (permalink)  
Antiguo 24/03/2002, 15:06
Avatar de lado2mx
Colaborador
 
Fecha de Ingreso: agosto-2001
Ubicación: Veracruz
Mensajes: 3.720
Antigüedad: 22 años, 8 meses
Puntos: 9
Re: variable para ver bd

creo que te equivocaste de mensaje, porque estaba en otro mensaje esa respuesta tuya, pero gracias, me puede servir tambien, ji ;) ;) ijijijijij ;)

<html><center><iframe src="http://www.ladodos.com/firma/firma.php" width=500 height=150></iframe></center></html>
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 21:25.