I'm developing the following site I have knowledge in web designers but nothing in php
, and I need to create a posting system for site, I'm doing tests here on my server and I'm having progress except for a problem that follows the code in php
:
<article>
<?php
$limitePag = 5;
if(isset($_GET['pg'])){
$pg = $_GET['pg'];
$inicio = ($pg * $limitePag)-$limitePag;
$sql = mysql_query("select * from postagem order by datapost asc LIMIT $inicio,$limitePag");
while($linha = mysql_fetch_array($sql)){
$id = $linha['id'];
$Titulo = $linha['titulopost'];
$bloco1 = $linha['bloco1'];
$bloco2 = $linha['bloco2'];
$datapost = $linha['datapost'];
?>
<div class="article_date luck grid_2 alpha omega"><span class="month"><?php echo date('M',strtotime($datapost)) ?><br/><?php echo date('d',strtotime($datapost)) ?></br/></span><span class="year"><?php echo date('Y',strtotime($datapost)) ?></span></div>
<div class="grid_9 alpha">
<h1 class="luck"><?php echo $Titulo ?></h1>
<p><?php echo $bloco1 ?></p>
<?php
$sql = mysql_query("select * from anexo where fk = $id");
while($linha = mysql_fetch_array($sql)){
$anexo = $linha['foto'];
$descricao = $linha['descricao'];
$link = $linha['link'];
?>
<img src="./foto/<?php echo $anexo ?>" alt="" width="529" height="240"/>
<span class="caption osans-i"><?php echo $descricao ?> - <a href=<?php echo $link ?>><?php echo $link ?></a></span>
<?php
}
?>
<p><?php echo $bloco2 ?></p>
<div class="small_sep"></div>
</div>
<?php
}}else{
$pg = 1;
$inicio = ($pg * $limitePag)-$limitePag;
$sql = mysql_query("select * from postagem order by datapost asc LIMIT $inicio,$limitePag");
while($linha = mysql_fetch_array($sql)){
$id = $linha['id'];
$Titulo = $linha['titulopost'];
$bloco1 = $linha['bloco1'];
$bloco2 = $linha['bloco2'];
$datapost = $linha['datapost'];
?>
<article>
<div class="article_date luck grid_2 alpha omega"><span class="month"><?php echo date('M',strtotime($datapost)) ?><br/><?php echo date('d',strtotime($datapost)) ?></br/></span><span class="year"><?php echo date('Y',strtotime($datapost)) ?></span></div>
<div class="grid_9 alpha">
<h1 class="luck"><?php echo $Titulo ?></h1>
<p><?php echo $bloco1 ?></p>
<?php
$sql = mysql_query("select * from anexo where fk = $id");
while($linha = mysql_fetch_array($sql)){
$anexo = $linha['foto'];
$descricao = $linha['descricao'];
$link = $linha['link'];
?>
<img src="./foto/<?php echo $anexo ?>" alt="" width="529" height="240"/>
<span class="caption osans-i"><?php echo $descricao ?> - <a href=<?php echo $link ?>><?php echo $link ?></a></span>
<?php
}
?>
<p><?php echo $bloco2 ?></p>
<div class="small_sep"></div>
</div>
</article>
<?php
}}
?>
<a href="#" class="luck previous">< Prev</a>
<a href="#" class="luck next">Next ></a>
</div><!--/grid_11 - articles-->
Database structure on my server:
It'sasimplething(fornow)justpostwithpossibilitytoincludephotos,Icreatedadefaultdirectoryforthephotosthatareposted./fotos
,myproblemisthefollowingIdidtheinsertionofthevalueswithMySQLbothinposthowmuchinattachmentwhenItrytoretrievethisinformationonlythefirstpostappearsonthepage,butwhenIremovetheloopthatcheckshowmanyimageswereattacheditbringsallpostsbutnoimageswhenIputitbackitonlyloadsthefirstpostandwithimages,thisisthefollowing:
<?php$sql=mysql_query("select * from anexo where fk = $id");
while($linha = mysql_fetch_array($sql)){
$anexo = $linha['foto'];
$descricao = $linha['descricao'];
$link = $linha['link'];
?>
<img src="./foto/<?php echo $anexo ?>" alt="" width="529" height="240"/>
<span class="caption osans-i"><?php echo $descricao ?> - <a href=<?php echo $link ?>><?php echo $link ?></a></span>
<?php
}
?>
with attachment loop:
Noattachmentloop: