Foros del Web » Programando para Internet » PHP »

Ayuda con Codigo PHP

Estas en el tema de Ayuda con Codigo PHP en el foro de PHP en Foros del Web. Hola, me han pasado este codigo para crear una base de datos con sus tablas y sus correspondientes campos. Necesito que me asesoreis en los ...
  #1 (permalink)  
Antiguo 20/10/2006, 16:29
 
Fecha de Ingreso: octubre-2006
Mensajes: 12
Antigüedad: 17 años, 6 meses
Puntos: 0
Ayuda con Codigo PHP

Hola, me han pasado este codigo para crear una base de datos con sus tablas y sus correspondientes campos. Necesito que me asesoreis en los campos que llevaria cada tabla, xq me hago un lio. GRACIAS!
Código PHP:
<?
require ("configuracion.php");
include (
"head_panel.php");
$sql "SELECT * FROM ofertas WHERE num_oferta = 1";
$es mysql_query($sql$con) or die("Error al leer datos 1: ".mysql_error);
while(
$row mysql_fetch_array($es)){
$oferta_1 $row['id_anuncio'];
 }
 
$sql "SELECT * FROM ofertas WHERE num_oferta = 2";
$es mysql_query($sql$con) or die("Error al leer datos 2: ".mysql_error);
while(
$row mysql_fetch_array($es)){
$oferta_2 $row['id_anuncio'];
 }
 
$sql "SELECT * FROM ofertas WHERE num_oferta = 3";
$es mysql_query($sql$con) or die("Error al leer datos 3: ".mysql_error);
while(
$row mysql_fetch_array($es)){
$oferta_3 $row['id_anuncio'];
 }
?>
<style type="text/css">
<!--
.Estilo1 {
    font-family: "Courier New", Courier, mono;
    font-weight: bold;
}
.Estilo12 {font-size: 14px; font-family: "Trebuchet MS";}
-->
</style>
<p align="center">&nbsp;</p>
<div align="center">
  <table width="750" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
    <tr>
      <td width="251" height="21" bgcolor="#CCCCCC"><div align="center"><span class="Estilo1">OFERTA N&ordm; 1 </span></div></td>
      <td width="246" bgcolor="#CCCCCC"><div align="center"><span class="Estilo1">OFERTA N&ordm; 2 </span></div></td>
      <td width="245" bgcolor="#CCCCCC"><div align="center"><span class="Estilo1">OFERTA N&ordm; 3 </span></div></td>
    </tr>
  </table>
  <table width="750" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
    <tr>
      <td width="250" height="21" bgcolor="#FF9999"><div align="center"><span class="Estilo1">ANUNCIO N&ordm;: <? echo $oferta_1?></span></div></td>
      <td width="247" bgcolor="#FF9999"><div align="center"><span class="Estilo1">ANUNCIO N&ordm;: <? echo $oferta_2?></span></div></td>
      <td width="245" bgcolor="#FF9999"><div align="center"><span class="Estilo1">ANUNCIO N&ordm;: <? echo $oferta_3?></span></div></td>
    </tr>
  </table>
  <table width="750" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
    <tr>
      <td width="249" height="163" bgcolor="#FFFFFF"><div align="center">
          <form name="form1" method="post" action="cambiar_oferta.php">
            <p class="Estilo1">
              <input name="num_oferta" type="hidden" id="num_oferta" value="1">
            </p>
            <p class="Estilo1">id:
              <input name="num_anuncio" type="text" id="num_anuncio" size="15">
              <input type="submit" name="Submit" value="Cambiar">
            </p>
          </form>
      <span class="Estilo1">        </span></div></td>
      <td width="248" bgcolor="#FFFFFF"><div align="center">
        <form name="form2" method="post" action="cambiar_oferta.php">
          <p class="Estilo1">
            <input name="num_oferta" type="hidden" id="num_oferta" value="2">
          </p>
          <p class="Estilo1">id:
              <input name="num_anuncio" type="text" id="num_anuncio" size="15">
              <input type="submit" name="Submit2" value="Cambiar">
            </p>
        </form>
      <span class="Estilo1">    </span></div></td>
      <td width="245" bgcolor="#FFFFFF"><div align="center">
          <form name="form3" method="post" action="cambiar_oferta.php">
            <p class="Estilo1">
              <input name="num_oferta" type="hidden" id="num_oferta4" value="3">
  </p>
            <p class="Estilo1">id:
                <input name="num_anuncio" type="text" id="num_anuncio" size="15">
                <input type="submit" name="Submit22" value="Cambiar">
            </p>
          </form>
      <span class="Estilo1">    </span></div></td>
    </tr>
  </table>
  <table width="750" height="293" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="30" height="293">
        <div align="right">      </div></td>
      <td width="185"><table width="175" height="234" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FF9999">
        <tr>
          <th scope="col"><table width="170" height="226" border="0">
              <tr>
                <th height="119" scope="col"><? 
                    $sql 
"SELECT * FROM anuncios WHERE id='$oferta_1'";
$es mysql_query($sql$con) or die($unerror); 
while(
$row mysql_fetch_array($es)){
$predeterminada $row['predeterminada'];
$imagen $row[$predeterminada];
$precio $row['precio'];
$tipo $row['tipo'];
$localidad $row['localidad'];
$metros $row['num_metros'];
$zona $row['zona'];
$concepto $row['concepto'];
$dormitorios $row['num_dormitorios'];

}
if (
$imagen==""){ echo "no";
}
else
{echo 
"<a href='../$pathimg2$oferta_1/$imagen' target='_blank'><img src='../$pathimg2$oferta_1/$imagen' width='143' height='105' border='1'></a>";}
                    
?></th>
              </tr>
              <tr>
                <td height="34"><? echo "<div align='center' class='Estilo17'>$precio &euro; </div>"?> </td>
              </tr>
              <tr>
                <td height="65" class="Estilo12"><div align="center"><? echo "<a href='../ver_anuncio.php?id=$oferta_1' class='Estilo13'>$tipo de $metros m&sup2; con $dormitorios dormitorios para $concepto en $localidad - $zona</a>"?></div></td>
              </tr>
          </table></th>
        </tr>
      </table></td>
      <td width="27">&nbsp;</td>
      <td width="271"><table width="175" height="234" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FF9999">
        <tr>
          <th scope="col"><table width="170" height="226" border="0">
              <tr>
                <th height="119" scope="col"><? 
                    $sql 
"SELECT * FROM anuncios WHERE id='$oferta_2'";
$es mysql_query($sql$con) or die($unerror); 
while(
$row mysql_fetch_array($es)){
$predeterminada2 $row['predeterminada'];
$imagen2 $row[$predeterminada2];
$precio2 $row['precio'];
$tipo2 $row['tipo'];
$localidad2 $row['localidad'];
$metros2 $row['num_metros'];
$zona2 $row['zona'];
$concepto2 $row['concepto'];
$dormitorios2 $row['num_dormitorios'];
}
if (
$imagen==""){
}
else
{echo 
"<a href='../$pathimg2$oferta_2/$imagen2' target='_blank'><img src='../$pathimg2$oferta_2/$imagen2' width='143' height='105' border='1'></a>";}
                    
?></th>
              </tr>
  
            <tr>
                <td height="34"><div align="center"><? echo "<div align='center' class='Estilo17'>$precio2 &euro; </div>"?></div></td>
              </tr>
              <tr>
                <td height="65"><div align="center"><? echo "<a href='../ver_anuncio.php?id=$oferta_2' class='Estilo13'>$tipo de $metros2 m&sup2; con $dormitorios2 dormitorios para $concepto2 en $localidad2 - $zona2</a>"?></div></td>
              </tr>
          </table></th>
        </tr>
      </table></td>
      <td width="237"><table width="175" height="234" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FF9999">
          <tr>
            <th scope="col"><table width="170" height="226" border="0">
                <tr>
                  <th height="119" scope="col"><? 
                    $sql 
"SELECT * FROM anuncios WHERE id='$oferta_3'";
$es mysql_query($sql$con) or die($unerror); 
while(
$row mysql_fetch_array($es)){
$predeterminada3 $row['predeterminada'];
$imagen3 $row[$predeterminada3];
$precio3 $row['precio'];
$tipo3 $row['tipo'];
$localidad3 $row['localidad'];
$metros3 $row['num_metros'];
$zona3 $row['zona'];
$concepto3 $row['concepto'];
$dormitorios3 $row['num_dormitorios'];
}
if (
$imagen==""){
}
else
{echo 
"<a href='../$pathimg2$oferta_3/$imagen3' target='_blank'><img src='../$pathimg2$oferta_3/$imagen3' width='143' height='105' border='1'></a>";}
                    
?></th>
                </tr>
                <tr>
                  <td height="34"><div align="center"><? echo "<div align='center' class='Estilo17'>$precio3 &euro; </div>"?></div></td>
                </tr>
                <tr>
                  <td height="65"><div align="center"><? echo "<a href='../ver_anuncio.php?id=$oferta_3' class='Estilo13'>$tipo de $metros3 m&sup2; con $dormitorios3 dormitorios para $concepto3 en $localidad3 - $zona3</a>"?></div></td>
                </tr>
            </table></th>
          </tr>
      </table></td>
    </tr>
  </table>
</div>
  #2 (permalink)  
Antiguo 20/10/2006, 19:36
 
Fecha de Ingreso: abril-2005
Mensajes: 491
Antigüedad: 19 años
Puntos: 1
Ijole mi opinión personal, es que es un poco complicado lo que quieres hacer con tan solo mostrar ese código que colocar ahí.

Pero por lo que puedo ver es que hay 2 tablas
Anuncios y Ofertas y que estas estan referenciadas unas con otras.

sabes de bases de datos ?, si ya tienes alguna idea al respecto, puedes darte una vuelta por aqui
http://www.mysql-hispano.org/
  #3 (permalink)  
Antiguo 20/10/2006, 19:36
 
Fecha de Ingreso: agosto-2003
Mensajes: 398
Antigüedad: 20 años, 7 meses
Puntos: 0
Ejemplo de campo de tabla:

$row['num_dormitorios']; --> El campo seria num_dormitorios

Ejemplo de Tabla:

SELECT * FROM ofertas WHERE num_oferta = 3 ---> La tabla seria ofertas


Saludos
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 08:08.