Álbum de fotos
Então pessoal, sou novo ainda em php, qualquer dica será bem vinda, vou postar aqui o que ja foi feito, pelo o que vcs percebem os codigos estão bem simples, pois é para eu mesmo entender.
cadastrar_evento.php // formulario que cadastra os eventos
<form action="cadastrar_evento_db.php" method="post" enctype="multipart/form-data">
<table width="512" border="0" align="center" cellpadding="5" cellspacing="1">
<tr> </tr>
<tr>
<th width="206" align="right" scope="col"><div align="right"><strong> <font size="1" face="Verdana, Arial, Helvetica, sans-serif">Nome:</font></strong></div></th>
<th width="392" scope="col"><div align="left">
<input name="nome" type="text" id="nome" />
</div></th>
</tr>
<tr>
<th align="right" scope="col"><div align="right"> <font size="1" face="Verdana, Arial, Helvetica, sans-serif">Data:</font>
</div></th>
<th align="left" scope="col"><div align="left">
<input name="data" type="text" id="data" />
</div></th>
</tr>
<tr>
<th align="right" scope="col"> <font size="1" face="Verdana, Arial, Helvetica, sans-serif">Local:
</font></th>
<th align="left" scope="col"><input name="local" type="text" id="local" /></th>
</tr>
<tr>
<th scope="col"> <div align="right"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Diretorio:
</font></div></th>
<th scope="col"><div align="left">
<input name="diretorio" type="text" id="diretorio" />
</div></th>
</tr>
<tr>
<th scope="col"> </th>
<th scope="col"><input type="submit" name="Submit" value="Cadastrar" /></th>
</tr>
</table>
</form>
cadastrar_evento_db.php // envia os dados para o banco
<?
include("conectdb.php");
$sql = "INSERT INTO eventos (nome, data, local, diretorio) VALUES ('$nome','$data','$local','$diretorio')";
mysql_query($sql) or die (mysql_error());mysql_close();//fecha conexão
?>
<? echo "<center><font size='3'>Cadastrado com sucesso";
?>
ver_eventos.php
<?
require ("conectdb.php");
$sql = "SELECT * FROM eventos ORDER BY id DESC LIMIT 9";
$limite = mysql_query("$sql");while ($sql = mysql_fetch_array ($limite) ) {
$id = $sql['id'];
$nome = $sql['nome'];
$data = $sql['data'];
?>
<a href="<? echo"evento.php?id=$id";?>"><? echo $nome ?></a><br>
<? echo $data ?>
<? } ?>
evento.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css"><!--
body {
background-color: #333333;
}
.style {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
color: #FFFFFF;
}
-->
</style>
</head>
<body>
<table width="730" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="90" bgcolor="#CCCCCC"> </td>
</tr>
<tr>
<td class="style"><?
require ("conectdb.php");
$sql = "SELECT * FROM eventos WHERE id='$id'";
$resultado = mysql_query("$sql");while ($sql = mysql_fetch_array ($resultado) ) {
$id = $sql['id'];
$nome = $sql['nome'];
$data = $sql['data'];
$local = $sql['local'];
$diretorio = $sql['diretorio'];
?>
<br><strong><?php echo $sql['nome']; ?></strong><br>
<?php echo $sql['data'] ?> - <?php echo $sql['local'] ?><? } ?></td>
</tr>
<tr>
<td><iframe name="fotos" src="<? echo"evento_fotos.php?id=$id";?>" width="750" height="430" scrolling="no" frameborder="0" marginwidth="0" marginheight="0" ></iframe></td>
</tr>
</table>
</body>
</html>
evento_fotos.php // então pessoal é nesta parte que eu preciso de ajuda, quero saber como dividir as fotos em duas colunas quero um album de fotos igual a esse http://www.baladasdailha.com.br/eventos_popup.php?id_evento=1467
<?
require ("conectdb.php");
$sql = "SELECT * FROM eventos WHERE id='$id'";
$resultado = mysql_query("$sql");while ($sql = mysql_fetch_array ($resultado) ) {
$id = $sql['id'];
$nome = $sql['nome'];
$data = $sql['data'];
$local = $sql['local'];
$diretorio = $sql['diretorio'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-color: #333333;
}
.style {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
color: #FFFFFF;
}
-->
</style>
</head>
<body>
<?php
// variável que define o diretório das imagens
$dir = "./fotos/$diretorio";
// esse seria o "handler" do diretório
$dh = opendir($dir);
// loop que busca todos os arquivos até que não encontre mais nada
while (false !== ($filename = readdir($dh))) {
// verificando se o arquivo é .jpg
if (substr($filename,-4) == ".jpg") {
// mostra o nome do arquivo e um link para ele - pode ser mudado para mostrar diretamente a imagem :)
echo "<img src=fotos/$diretorio/$filename width=350 height=265><br>";
}
}
?>
</body>
</html>
<? } ?>Discussão (1)
Carregando comentários...