Jump to content


Bruno Tanaka

Member Since 23/07/2009
Offline Last Active 18/08/2011, 13:10
-----

Topics I've Started

Código Para Exibir Informações Do Banco De Dados

18/08/2011, 09:31

Tenho um código muito simples, que busca informações no banco de dados e exibe na página.
Porém não está exibindo na página, já revisei o código e não consigo encontrar o erro.

abaixo está o código:

<?php
include "conexao.php";

?>


<html>
<head>

<title></title>
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=iso-8889-1" />
</head>

<script type="text/javascript">
function somaClick(id){
var passou = true;

if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
passou = true
}
}
var str = "ajax2.php?id="+id;

xmlhttp.open("GET",str,true);
xmlhttp.send();
return passou;
}
</script>
<body>

<style>
body {
font-size:14px;
font-family:arial;
margin:0px;
}
.descricao {
width:250px;
height:85px;
padding-top:5px
}
.titulo {
width:120px;
color:#369 !important;
font-weight:bold;0
}
#linha {
padding: 9px 15px;
*padding-top:9px;
*padding-left:15px;
*padding-right:0px;
*padding-bottom:0px;
float:left;

}
#imagem {
width:85px;
height:103px;
*height:105px;
float:left;
background-color:#F4F4F4;
}
#conteudo {
float:left;
height:95px;
*height:105px;
width:150px;
background-color:#F4F4F4;
font-size:12px !important;
padding:4px
}
a{
text-decoration:none;
color:black
}
a:hover {
text-decoration:underline;
}

</style>
<?php
echo '
<div style="width:560px; height:450px; border:1px solid; border-color:#ebebeb;">
<img src="img/market.jpg" alt="Market Place" width="560" height="25" title="Market Place" />
';
?>
<?php
$string = "SELECT * FROM publicadores WHERE status =1 and fim > NOW() ORDER BY RAND() LIMIT 0,6";
$sql = mysql_query($string);

while ($array = mysql_fetch_array($sql)){
$str = "SELECT * FROM anuncios WHERE publicador='".$array['id']."' and data_final > NOW() and status=1 ORDER BY RAND()";
$query = mysql_query($str);
$res = mysql_fetch_array($query);
if ($res['id']!=0){
$ip = $_SERVER["REMOTE_ADDR"];
$st2 = "INSERT INTO impressoes VALUES (null,'".$res['id']."','".$ip."',NOW(),NOW())";
$sq2 = mysql_query($st2);
}
if (mysql_num_rows($query)>0){


echo '
<div id="linha">

<div class="titulo">
<a href="'.$res['url'].'" target="_blank" style="color:#369 !important;" onclick="return somaClick('.$res['id'].')">'.$array['nome'].' </a></div>

<a href="'.$res['url'].'" target="_blank" style="color:#369" onclick="return somaClick('.$res['id'].')">
<div class="descricao">

<div id="imagem">
<img style="border:0px solid !important" src="imagens/'.$res['imagem'].'" width="85px" height="85px" />
</div>
<div id="conteudo">
<span>
<strong>'.$res['titulo'].'</strong><br />
<span style="color:black !important">'.
substr($res['descricao'],0,108).
'</span><br />


</span>
</div>
</a>
</div>
</div>

';
}


}

?>



<?php
echo'</div>';
?>
</body>
</html>


---

OBS: o arquivo conexao.php está funcionando corretamente.
Se alguem conseguir achar o erro, por favor me da a dica...

Grande abraço!

IPB Skin By Virteq