Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Será que alguém pode me dar uma força?!?!
Preciso fazer um laço de repetição nesta página www.gomesegomes.net/teste/imob.php
Ela precisa ficar como estawww.gomesegomes.net/teste/imob.html
Segue o código que estou tentando fazer:
<?php require_once('Connections/conexao.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;$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_rs_imovel = 2;
$pageNum_rs_imovel = 0;
if (isset($_GET['pageNum_rs_imovel'])) {
$pageNum_rs_imovel = $_GET['pageNum_rs_imovel'];
}
$startRow_rs_imovel = $pageNum_rs_imovel * $maxRows_rs_imovel;
mysql_select_db($database_conexao, $conexao);
$query_rs_imovel = "SELECT * FROM imovel ORDER BY id ASC";
$query_limit_rs_imovel = sprintf("%s LIMIT %d, %d", $query_rs_imovel, $startRow_rs_imovel, $maxRows_rs_imovel);
$rs_imovel = mysql_query($query_limit_rs_imovel, $conexao) or die(mysql_error());
$row_rs_imovel = mysql_fetch_assoc($rs_imovel);
if (isset($_GET['totalRows_rs_imovel'])) {
$totalRows_rs_imovel = $_GET['totalRows_rs_imovel'];$all_rs_imovel = mysql_query($query_rs_imovel);
$totalRows_rs_imovel = mysql_num_rows($all_rs_imovel);
}
$totalPages_rs_imovel = ceil($totalRows_rs_imovel/$maxRows_rs_imovel)-1;
$queryString_rs_imovel = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {array_push($newParams, $param);
}
}$queryString_rs_imovel = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_rs_imovel = sprintf("&totalRows_rs_imovel=%d%s", $totalRows_rs_imovel, $queryString_rs_imovel);
?>
<!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](http://www.w3.org/1999/xhtml)">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="resource-type" content="document" />
<meta http-equiv="pragma" content="no-cache" />
<meta name="classification" content="Internet" />
<meta name="Keywords" content="Construtora, Engenharia, Imobiliária, Corretor, Imóveis" />
<meta name="Description" content="Empresa atuante em vários segmentos do mercado, voltada principalmente à comercialização de imóveis, prestando assessoria jurídica, além de regularização de projetos de imóveis junto à prefeitura. Atua, também, na Construção Civil e Engenharia da Segurança do Trabalho. Seu quadro de colaboradores é formado por Engenheiro, Advogado e Corretor de Imóveis, sendo que estes profissionais estão devidamente cadastrados em suas respectivas entidades de classe." />
<meta name="robots" content="ALL" />
<meta name="distribution" content="Global" />
<meta name="rating" content="General" />
<meta name="author" content="Design V7 -[www.designv7.com.br](http://www.designv7.com.br/) - 11 4771-6446" />
<meta name="language" content="pt-br" />
<meta name="doc-class" content="Completed" />
<meta name="doc-rights" content="Public" />
<title>Gomes & Gomes</title>
<link href="css/estilo.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="900" height="650" border="0" align="center" cellpadding="0" cellspacing="0" class="entrada">
<tr>
<td align="center" valign="top"><table width="850" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="90" align="left" valign="middle" class="imob_top"><a href="index.html"><img src="images/logo_imb.png" width="350" height="74" alt="logo" /></a></td>
<td align="right" valign="middle" class="imob_top"><span class="texto_azul" style="font-variant:small-caps"><br />
Tel/Fax 11 4701-2058<br />
<a href="mailto:imoveis@gomesegomes.net">imoveis@gomesegomes.net</a></span></td>
</tr>
</table></td>
</tr>
<tr>
<td height="48" align="center" valign="top">
<!-- MENU -->
<table width="850" height="48" border="0" align="center" cellpadding="0" cellspacing="1" class="menu-hh">
<tr>
<td width="159" align="center" valign="middle" class="tamanho"><li style="width:100%"><a href="index.html">Início</a></li></td>
<td width="159" align="center" valign="middle" class="tamanho"><li style="width:100%" class="menu-hh2"><a href="imob.html">Imóveis a Vendas</a></li></td>
<td width="159" align="center" valign="middle" class="tamanho"><li style="width:100%"><a href="anuncie.html">Anuncie seu Imóvel</a></li></td>
<td width="159" align="center" valign="middle"><li style="width:100%" class="menu-hh3"><a href="assessoria.html">Assessoria na <br />
Compra e Venda</a></li></td>
<td width="159" align="center" valign="middle" class="tamanho"><li style="width:100%"><a href="contato.html">Contato</a></li></td>
<td> </td>
</tr>
</table>
<!-- MENU -->
</td>
</tr>
<tr>
<td height="430" align="center" valign="top">
<table width="850" height="430" border="0" align="center" cellpadding="5" cellspacing="0" class="imob_box">
<tr>
<td valign="top">
<?php do { ?>
<table width="100%" border="0" cellspacing="10" cellpadding="0">
<tr>
<td align="center" valign="top"><a href="detalhe.html"><img src="admin/imagens/<?php echo $row_rs_imovel['imagem']; ?>" width="170" height="110" /></a></td>
</tr>
<tr>
<td class="texto"><span class="texto_vermelho"><?php echo $row_rs_imovel['valor']; ?></span></td>
</tr>
<tr>
<td class="texto"><strong>Bairro:</strong> <?php echo $row_rs_imovel['bairro']; ?><br />
<?php echo $row_rs_imovel['descricao']; ?></td>
</tr>
</table>
<?php } while ($row_rs_imovel = mysql_fetch_assoc($rs_imovel)); ?>
</td>
</tr>
<tr>
<td height="8" colspan="4" align="center">
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<table border="0">
<tr>
<td><?php if ($pageNum_rs_imovel > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_rs_imovel=%d%s", $currentPage, 0, $queryString_rs_imovel); ?>"><<</a>
<?php } // Show if not first page ?></td>
<td><?php if ($pageNum_rs_imovel > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_rs_imovel=%d%s", $currentPage, max(0, $pageNum_rs_imovel - 1), $queryString_rs_imovel); ?>"><</a>
<?php } // Show if not first page ?></td>
<td><?php if ($pageNum_rs_imovel < $totalPages_rs_imovel) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_rs_imovel=%d%s", $currentPage, min($totalPages_rs_imovel, $pageNum_rs_imovel + 1), $queryString_rs_imovel); ?>">></a>
<?php } // Show if not last page ?></td>
<td><?php if ($pageNum_rs_imovel < $totalPages_rs_imovel) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_rs_imovel=%d%s", $currentPage, $totalPages_rs_imovel, $queryString_rs_imovel); ?>">>></a>
<?php } // Show if not last page ?></td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table></td>
</tr>
<tr>
<td height="60" align="center" valign="middle" class="texto_azul"><span style="font-size:14px"> Praça Miguel Ortega, 380 - Sala 5 - Taboão da Serra/SP<br />
©Todos os direitos reservados - 2013</span></td>
</tr>
</table>
</body>
</html>Oi dedas, obrigada pelo retorno, e desculpe minha ignorância, pois estou fazendo isso de atrevida afinal não entendo nada de PHP.
Preciso que essa "tabela" busque do banco os imóveis que tenho cadastrado, e mostre de 8 em 8 com paginação.
Tentei colocar no seu código as informações do imóvel, mas não deu certo a syntax...
<div style="width:630px; height:630px; margin:0px auto;">
<?php
for($counter = 1; $counter <= 8; ++$counter){
echo '<div style="width:200px; height:200px; background:blue; float:left; margin:5px;"><a href="detalhe.html"><img src="admin/imagens/<?php echo $row_rs_imovel['imagem']; ?>" width="170" height="110" /></a></div>';
}
?>
</div>
Você pode me ajudar? Please...rs
É bastante simples :) Eu não faria esse laço em uma tabela, usaria em divs :) Acho mais fácil de manipular ^^
Segue abaixo um exemplo muuuuito simples de como você pode fazer isso ;)