Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá pessoal, seguinte, estou com problemas na hora de exibir noticias no sistema php que eu estou desenvolvendo. Quando faço o while para mostrar as noticias que estão cadastradas no banco de dados. O modo como eu estou querendo exibir e tipo duas noticias uma do lado da outra, estilo temas magazine do wordpress, onde são exibidas 2 noticias por linha, porem não sei como fazer isso, quando tento fazer ou sai uma embaixo da outra ou uma do lado da outra mais nunca de duas em duas
se puderem me ajuda. Agradeço desde ja
<?php require_once('Connections/project_zyzz.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_project_zyzz, $project_zyzz);
$query_Recordset1 = "SELECT * FROM posts ORDER BY id DESC";
$Recordset1 = mysql_query($query_Recordset1, $project_zyzz) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<style>
.video {
position:relative;
top:-35px;
}
.post {
position:relative;
width:340px;
}
</style>
<table width="980" border="0" align="center">
<tr>
<td width="680" height="246"><?php include 'slide.php'; ?></td>
<td width="290"><div class="video" ><iframe width="290" height="268" src="http://www.youtube.com/embed/z742eN2oE0I" frameborder="0" allowfullscreen></iframe></div></td>
</tr>
</table>
<table width="980" style="height:auto;"border="0" align="center" >
<tr>
<?php do { ?>
<td width="827" height="88" valign="bottom" style="width:auto;" ><table width="720" border="0">
<tr>
<td><table width="340" border="0" >
<tr>
<td width="340" height="38" align="center"><img src="<?php echo $row_Recordset1['img_post']; ?>" width="340" height="159" /></td>
</tr>
<tr>
<td ><?php echo $row_Recordset1['desc_post']; ?></td>
</tr>
<tr>
<td></td>
</tr>
</table></td>
</tr>
</table></td> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</tr>
</table>
<p> </p>
<?php
mysql_free_result($Recordset1);
?>
ta ai o codigo parça, me explica como que eu faço isso ae fazendo um favor :D
Vc quer duas em duas por categoria? É isso?
Isso aí ficou complicado de entender
O modo como eu estou querendo exibir e tipo duas noticias uma do lado da outra, estilo temas magazine do wordpress, onde são exibidas 2 noticias por linha, porem não sei como fazer isso, quando tento fazer ou sai uma embaixo da outra ou uma do lado da outra mais nunca de duas em duas
Assim brother pelo que parece você esta montando o site dentro de uma tabela
isso não é muito legals e tals não tem nada semantico e depois para dar manutenção no codigo fica muito dificil.
te aconselho a usar div tabela somente quando for criar um dado que realmente seja tabular e não para definir o layout do site
Da uma estudada sobre CSS.
montei aqui um modelinho rapido com seu código algo bem simples mais da pra você ter uma idéia de como montar com css
<?php require_once('Connections/project_zyzz.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_project_zyzz, $project_zyzz);
$query_Recordset1 = "SELECT * FROM posts ORDER BY id DESC";
$Recordset1 = mysql_query($query_Recordset1, $project_zyzz) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
<style type="text/css">
.main{width: 980px;}/*Tamanho da pagina*/
.limpar{clear: both; width: 100%; font-size: 100%;}/*limpa as div flutuantes*/
.topo div{float: left; margin-left: 3px;}/*faz as divs do topo ficarem uma do lado da outra com espaço de 3px entre elas*/
.slide{width: 680px;height: 246px;}/*Tamanho da div slide*/
.video{width: 290px;}/*Tamanho da div video*/
.box_noticias{width: 480px; height: 100px; float: left;}/*define o tamanho da div e faz elas ficarem uma do lado da outra*/
.box_noticias div{float: left; margin-left: 3px;}/*faz a div de imagem ficar do lado da div de descrição*/
</style>
</head>
<body>
<div align="center">
<div class="main">
<div class="topo">
<div class="slide"><?php include 'slide.php'; ?></div>
<div class="video"><iframe width="290" height="268" src="http://www.youtube.com/embed/z742eN2oE0I" frameborder="0" allowfullscreen></iframe></div>
<div class="limpar"></div>
</div>
<?php do { ?>
<div class="box_noticias">
<div><img src="<?php echo $row_Recordset1['img_post']; ?>"></div>
<div><?php echo $row_Recordset1['desc_post']; ?></div>
</div>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</div>
<div class="limpar"></div>
</div>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
Espero ter ajudado
E fica a dica estuda um pouco de css
alguns link's do portal imasters que podem ajudar
http://imasters.com.br/front-end/web-standards/semantica-html5-comece-agora-mesmo-use/
http://imasters.com.br/front-end/css/criando-uma-pagina-simples-de-forma-elegante-com-css3/
http://imasters.com.br/artigo/9065/css/posicionar-o-rodape-embaixo-da-janela/
http://imasters.com.br/artigo/2591/css/posicionando-e-estilizando-um-formulario-sem-uso-de-tabelas/
http://imasters.com.br/artigo/3692/web-standards/posicionamento-e-layouts-parte-03/
http://imasters.com.br/artigo/3638/web-standards/posicionamento-e-layouts-parte-02/
http://imasters.com.br/artigo/3606/web-standards/posicionamento-e-layouts/
valeu pela ajuda bro, o estilo que eu quero a pagina e tipo isso : https://lh5.googleusercontent.com/-zLfVJ8E6174/T4LsfFuytuI/AAAAAAAABgg/ib_qhlFdD7M/s1600/Blucent.jpg. Noticias uma do lado da outra. Brigadão ae pela força
Posta o seu codigo para facilitar, Isso que voce ta querendo é feito no Css, Basta voce da um float:left, ou rigth, estabelecer o width e o heigth e pronto!