Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/02/2008, 04:54
Avatar de Taribo007
Taribo007
 
Fecha de Ingreso: agosto-2007
Mensajes: 1.338
Antigüedad: 16 años, 8 meses
Puntos: 18
No acabo de entender el funcionamiento de PHP

por que si hago esto:

Código PHP:
<html>
<head>
<title>Prueba sencilla php conexion</title>
</head>

<body>
<?php 

$conexion 
mysql_connect("localhost","userbarros","barros2008") or die("No se pudo "); 
mysql_select_db("BDBARROS") or die("No se puede seleccionar BD"); 

$res=mysql_query("SELECT idComida FROM comidas"); 
//$arr=mysql_fetch_array($res); 

//si el select te retorna solo una tupla, lo haces asi
//echo $arr['idComida']; hay te imprime el id_usuario

//si te retorna varias tuplas lo haces con un ciclo
echo "<table border=1>";
while(
$arr=mysql_fetch_array($res)){
echo 
"<tr>";
echo 
"<td>".$arr['idComida']."</td>";
//echo $arr['idComida'];
//echo "<td>"; 
}
echo 
"</table>";
//te va a imprimir todos los id posibles que cumplan con esa condicion
?>

</body>
</html>
obtengo lo siguiente:

http://www.vinostierradebarros.com/prueba3.php

Si esta tabla, quiero cargarla en una celda concreta de una pagina html creada perviamente, no consigo que se inserte.

Código PHP:
<html><!-- InstanceBegin template="/Templates/tierrabarrosplantilla.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Description" content="Vinoteca Venta de vino local ocio"/>
<meta name="Keywords" content="vinos,compra,venta,tierra,barros,tierradebarros,vinostierradebarros,vino,comprar,vender,denominacion,añada,ocio,local,copas,tapas,pinchos"/>
<meta name="Robots" content="all"/>
<meta http-equiv="expires" content="-1"/>
<LINK REL="stylesheet" TYPE="text/css" HREF="ejemplo.css">
<title>Tierra de Barros-&gt;-&gt;Venta de vino -&gt;-&gt; Local de ocio</title>
</head>
<body>
<table width="100%" height="100%"  border="0" align="center">
  <tr align="center" valign="middle">
    <td width="120" height="100%"><table width="120" height="100%"  border="0" align="center">
      <tr>
        <td width="120" align="center" valign="top"><img src="imagenes/menu.gif" width="120" height="190"></td>
      </tr>
      <tr>
        <td width="120" align="center" valign="middle"><p class="textoblanco">-- -- -- -- -- -- -- -- --</p>
            <P class="textomenu"><a href="tierrabarroslocal.html">- El local -</a> </P>
            <P class="textomenu"><a href="tierrabarrospintxos.php">- Pintxos - </a></P>
            <P class="textomenu"><a href="tierrabarrosvinos.html">- Vinos - </a></P>
            <P class="textomenu"><a href="tierrabarroscomollegar.html">- Como llegar -</a> </P>
          <p class="textoblanco">-- -- -- -- -- -- -- -- --</p></td>
      </tr>
      <tr>
        <td width="120" align="center" valign="bottom"><img src="imagenes/menu.gif" width="120" height="190"></td>
      </tr>
    </table></td>
    <td width="100%" height="100%"><table width="100%" height="100%"  border="0">
      <tr>
        <td width="100%" height="100%" align="center" valign="middle"><!-- InstanceBeginEditable name="RegionEditable" -->
          <table width="100%" height="100%" border="0">
            <tr height="20%" align="center" valign="middle">
              <td  width="50%" height="20%" align="center" valign="top"><marquee height="100%" width="75%" align="absmiddle" behavior="slide" direction="right"><img src="imagenes/EtiPintxos.gif" width="218" height="79"></marquee></td>
              <td  width="50%" height="20%" align="center" valign="top"><marquee height="100%" width="75%" align="absmiddle" behavior="slide" direction="left"><img src="imagenes/EtiTablas.gif" width="217" height="79"></marquee></td>
            </tr>
            <tr height="80%">
              <td  height="80%"align="center" valign="top">
<?php
$conexion 
mysql_connect("localhost","userbarros","barros2008") or die("No se pudo ");
mysql_select_db("BDBARROS") or die("No se puede seleccionar BD");

$res=mysql_query("SELECT IdComida FROM Comidas",$conexion);
//$arr=mysql_fetch_array($res);

echo "<table border=1>";
while(
$arr=mysql_fetch_array($res)){
echo 
"<tr>";
echo 
"<td>".$arr['IdComida']."</td>";
}
echo 
"</table>";
?>
              </td>
            </tr>
          </table>

          <!-- InstanceEndEditable --></td>
      </tr>
      <tr>
        <td width="100%" height="100%" align="left" valign="bottom"><img src="imagenes/logomediano.gif" width="685" height="105"></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
<!-- InstanceEnd --></html>
El resutado obtenido es:

http://www.vinostierradebarros.com/t...ospintxos1.php

Ya se que es un tocho, ya lo tenia funcionando con asp y me he tenido que pasar a php y no lo logro.

Un saludo y gracias