Forum Moderators: not2easy
i have a MySQL table. It contains the personal data of some friends of mine and their photo.
Now I want to create, a page that shows all that, something like this:
<snip>
But i can't get it..I have tried it, and i get this:
<snip>
These are my codes, can you help me?
#page-container {
background: grey;
margin: auto;
}#parte-superior {
height: 200px;
background: green;
}
#contactos {
background: white;
margin: auto;
width: 700px;
}
#foto {
width: 300px;
float: left;
background: yellow;
}
#datos {
width: 400px;
background: red;
}
<html>
<head>
<style type="text/css" media="all">@import "css/master.css";</style>
</head><body>
<div id="page-container">
<div id="parte-superior">
Hola mundo
</div>
<div id="contactos">
<div id="foto">
<?php
// Nos conectamos al servidor mysql.
mysql_connect("localhost", "root", "") OR die(mysql_error());
// Seleccionamos la base de datos "red_social".
mysql_select_db("red_social") OR die(mysql_error());
// Visualizamos el contenido de la tabla "amigos".
$result = mysql_query("select * from amigos") OR die(mysql_error());
// Imprimimos las filas de la tabla "amigos".
while($row = mysql_fetch_array($result))
{
// Mostramos la imagen.
$pru=$row["avatar"];
echo "<img src='$pru'>";
?>
</div>
<div id="datos">
<?php
echo $row["nombre"];
echo "<br>";
echo $row["apellidos"];
echo "<br>";
echo $row["edad"];
echo "<br>";
echo $row["telefono"];
echo "<br>";
echo $row["email"];
echo "<br>";
echo $row["domicilio"];
echo "<br>";
echo $row["perfil"];
echo "<br>";
}
?>
</div>
</div>
</div>
</body>
</html>
Ciao
[edited by: swa66 at 9:52 pm (utc) on Nov. 30, 2008]
[edit reason] No personal URLs, please see forum charter [/edit]
im startin with css and now i trying to know how the classes work.
I have a ccs file with two classes, and a html/php/mysql document where i'm trying to apply the
rules of the classes ( "class foto -> background: yellow;" and
"class datos -> background: color;") but I can't see put them into practice anywhere...
What am i doing wrong?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style type="text/css" media="all">@import "css/master.css";</style>
</head><body>
<div id="page-container">
<div id="parte-superior">
Hola mundo
</div>
<div id="contactos">
<?php
// Nos conectamos al servidor mysql.
mysql_connect("localhost", "root", "") OR die(mysql_error());
// Seleccionamos la base de datos "red_social".
mysql_select_db("red_social") OR die(mysql_error());
// Visualizamos el contenido de la tabla "amigos".
$result = mysql_query("select * from amigos") OR die(mysql_error());
// Imprimimos las filas de la tabla "amigos".
while($row = mysql_fetch_array($result))
{
?>
<div class="foto">
<?php
// Mostramos la imagen.
$pru=$row["avatar"];
echo "<img src='$pru'>";
?>
</div>
<div class="datos">
<?php
echo $row["nombre"];
echo "<br>";
echo $row["apellidos"];
echo "<br>";
echo $row["edad"];
echo "<br>";
echo $row["telefono"];
echo "<br>";
echo $row["email"];
echo "<br>";
echo $row["domicilio"];
echo "<br>";
echo $row["perfil"];
}
?>
</div>
</div>
</div>
</body>
</html>
#page-container {
background: grey;
margin: auto;
}#parte-superior {
height: 200px;
background: green;
}
#contactos {
background: white;
margin: auto;
width: 700px;
}
div.foto {
width: 300px;
float: left;
background: yellow;
}
div.datos {
width: 400px;
background: red;
}
Aside of that, only the css and the html are given to the browser, so whatever you have in php or databases isn't that relevant, the generated html is all the more.
Make sure your generated code validates
[validator.w3.org...]
[jigsaw.w3.org...]
To get the generated html: view it in your browser and do a view source ...