Jump to content


Henrique Flausino

Member Since 31/07/2007
Offline Last Active 21/10/2011, 20:12
-----

Topics I've Started

Calcular Idade

18/10/2011, 10:47

Pessoal estou com uma duvida.
Tenho o seguinte código, mas quero que ele calcule diretamente da seleção de uma combo.
<?php
function calcular_idade( $ano_de_nasc ){
$ano_de_hoje = date("Y");
$idade = $ano_de_hoje - $ano_de_nasc;
echo $idade;
}
calcular_idade("1996");
?>
Como posso fazer isso?
Alguém me ajuda?
Nome da combo é propertyyearbuilt2

Tentei assim e não funcionou.

<?php
function calcular_idade( $ano_de_nasc ){
$ano_de_hoje = date("Y");
$idade = $ano_de_hoje - $ano_de_nasc;
echo $idade;
}
calcular_idade($propertyyearbuilt2);
?>

Problema Com Busca Randonica

11/10/2011, 15:43

Boa tarde.

Estou com um problema em uma busca dinamica entre duas tabelas.
Preciso que seja mostrado resultados dinamicos e que alterem a cada atualização da página e a cada acesso.
abaixo o código funciona normalmente, porém preciso que seja mostrado apenas a cidade, que esta em uma tabela separada.
Se colocar o endereço aparece corretamente, porém a cidade está alternando com o estado.

Segue código.
<?php
{
require ( "includes/config.php" );
require ( "includes/CGI.php" );
require ( "includes/SQL.php" );
  
  $cgi = new CGI ();
  $sql = new SQL ( $DBusername, $DBpassword, $server, $database );

  if ( ! $sql->isConnected () )
  {
    die ( $DatabaseError );
  }
   require ( "includes/CSQL.php" ); 
  $rows = $sql->execute ( "SELECT * FROM $property_table, $cidade_table WHERE propertyshow = '1' ORDER BY RAND() LIMIT 1",
  SQL_RETURN_ASSOC );
  $row = $rows [ 0 ];
 {
 print "<p><a href=\"index.php?op=mi&id=$row[id]\">";
 if ($row [ 'propertyphoto1' ] ){ print "<IMG SRC=\"".$ImageURL."$row[propertyphoto1]\" BORDER=\"0\" WIDTH=\"$max_thumb_image_width\" HEIGHT=\"$max_thumb_image_height\">";}
 else { print "<IMG SRC=\"".$ImageURL."nopropertyimage.jpg\" BORDER=\"0\" WIDTH=\"$max_thumb_image_width\" HEIGHT=\"$max_thumb_image_height\">";}
 print "</a><br>$row[descricao]
 </p>";
 {
 }
 print "<p><a href=\"index.php?op=mi&id=$row[id]\">";
 if ($row [ 'propertyphoto2' ] ){ print "<IMG SRC=\"".$ImageURL."$row[propertyphoto2]\" BORDER=\"0\" WIDTH=\"$max_thumb_image_width\" HEIGHT=\"$max_thumb_image_height\">";}
 else { print "<IMG SRC=\"".$ImageURL."nopropertyimage.jpg\" BORDER=\"0\" WIDTH=\"$max_thumb_image_width\" HEIGHT=\"$max_thumb_image_height\">";}
 print "</a><br>$row[descricao]</p>";

}
}
    ?>

Alguém me ajuda?

Esqueci de colocar o banco.

Banco properties.

id	agentref	propertyoption		propertyref 	propertytype 	propertyprice 	propertybedrooms 	propertybathrooms 	propertyyearbuilt 	propertylivingarea 	propertyplotsize 	propertyaddress 	propertyestado 	propertycidade 	propertybairro 	propertypostcode		propertycountry 	shortdescription	 	longdescription				propertystatus 		propertyphoto1 				propertyphoto2 	propertyphoto3 	propertyphoto4 	propertyphoto5 	propertyphoto6 	propertyphoto7 	propertyphoto8 	propertyphoto9 	propertyphoto10 	propertyviews 	propertyshow 	featuredproperty 	virtualtour 	propertyowner 						dateadded
30	   			S		     1002	     2		   46000		1			2			1890			1300			1400		Av. Sapopemba			4		5		5	   03374-000						Breve descrição do Imóvel 	Descrição do Imóvel				2		1002-32-1143225528_offer_27_e.jpg 	  	  	  	  	  	  	  	  	  												0	 	1 		N 	  			Esta informação não é exibida no site. É para sua ... 	11/10/2011 14:20
29	   			S		     1002	     2		   46000		1			2			1890			1300			1400		Av. Sapopemba			4		5		5	   03374-000						Breve descrição do Imóvel 	Descrição do Imóvel				2		1002-32-1143225528_offer_27_e.jpg 	  	  	  	  	  	  	  	  	  												0	 	1 		N 	  			Esta informação não é exibida no site. É para sua ... 	11/10/2011 14:20


Banco cidade.
codigo 	cod_estado 	descricao
  4    	   5    	Rio de Janeiro
  5 	   4    	São Paulo

Alteração Em Busca

20/08/2011, 19:14

Boa noite.

Caros.

Tenho um código que estou tentando alterar mas não consigo.
Alterei a tabela do MYSQL para poder cadastrar Estado, Cidade e Bairro, porém não consigo ajustar o código para pesquisar.
Será que alguém poderia me ajudar?

Segue tabela:
admin, bairro, cidade, configure, estado, features, properties, propertyfeatures, propertylocations, propertystatus, propertytypes

Sendo que o propertylocations é o original e eu vou excluir.

Estrutura das tabelas.
Estado:
Id, Descricao
Cidade:
codigo, cod_estado, descricao
Bairro:
codigo, cod_cidade, descricao
properties:
id, agentref, propertyoption, propertyref, propertytype, propertyprice, propertybedrooms, propertybathrooms, propertyyearbuilt, propertylivingarea, propertyplotsize, propertyaddress, propertylocationestado, propertylocationcidade, propertylocationbairro, propertypostcode, propertycountry, shortdescription, longdescription, propertystatus, propertyphoto1, propertyphoto2, propertyphoto3, propertyphoto4, propertyphoto5, propertyphoto6, propertyphoto7, propertyphoto8, propertyphoto9, propertyphoto10, propertyviews, propertyshow, featuredproperty, virtualtour, propertyowner, dateadded

Código fonte.
index.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>SGM Imóveis</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="images/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #000000}
.style3 {font-size: 14px}
.style12 {
	font-size: 11px;
	color: #000;
}
.style10 {font-size: 12px}
body {
	background-image: url(images/bg.gif);
}
-->
</style>
&lt;script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
&lt;script language="JavaScript" type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>
</head>

<body>
<table width="980" height="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr> 
    <td width="750" height="250" align="center">
    <table width="100%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="center"><img src="images/logo.jpg" width="990" height="250" class="logo" /></td>
      </tr>
    </table></td>
  </tr>
  <tr> 
    <td valign="top">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F2F2F2">
        <tr> 
          <td width="150" rowspan="2" valign="top"><table width="192" border="0" cellspacing="0" cellpadding="0">
              
              <tr>
                <td align="left" valign="middle">
                <div class="menu-imob"><br />
                	<ul>
                    	<li class="bullets"><a href="index.php">Principal</a></li> 
                        <li class="bullets"><a href="#" target="_top" onClick="MM_openBrWindow('cadastro/index.php','Cadastro','scrollbars=yes,width=650,height=480')"> Cadastre seu Imóvel</a></li>
                         
                        <li class="bullets"><a href="index.php?op=search&po=S" target="_top"> Imóveis para Venda</a></li> 
                        <li class="bullets"><a href="index.php?op=search&po=R" target="_top"> Imóveis para Aluguel</a></li> 
                        <li class="bullets"><a href="#" onClick="window.open('contato.php','Janela','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=461,height=260'); return false;">Fale Conosco</a><br></li>
                	</ul>
</div>
                <br><strong><span class="style12">     Busca Avançada</span></strong><br><?php include ("includes/templates/inc-searchbox.php"); ?></td>
              </tr>
              <td align="left" valign="middle">           
  <!-- start of searchbox include -->
  <!-- end of searchbox include -->
   <strong> </strong>
   <strong>  </strong><!-- end of price box include --></td>
              </tr>
			  <tr>
                <td align="center" valign="middle"><img src="images/white-dot.gif" width="192" height="1"></td>
              </tr>
              <tr>
                <td align="left" valign="middle"> </td>
              </tr>
              <tr>
                <td align="center" valign="middle"><table width="90%"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td align="left" valign="middle"><p><strong><span class="style12">Busca por Cidade do Imóvel</span></strong><span class="style10">
                    <!-- start of location box include -->
                    </span> </p>
                      <blockquote>
                        <?php include ("includes/templates/inc-locations2.php"); ?>
                      </blockquote>
<p><strong><span class="style12">Busca por Bairro do Imóvel</span></strong><span class="style10">
  <!-- start of location box include -->
  </span>
</p>
                      <blockquote>
                        <?php include ("includes/templates/inc-locations.php"); ?>
                    </blockquote></td>
                  </tr>
                </table>                  <!-- end of location box include --></td>
              </tr>
              <tr>
                <td align="left" valign="middle"> </td>
              </tr>
              <tr>
                <td align="center" valign="middle"><img src="images/white-dot.gif" width="192" height="1"></td>
              </tr>
              <tr>
                <td align="left" valign="middle"> </td>
              </tr>
              <tr>
                <td align="center" valign="middle"><table width="90%"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td align="left" valign="middle"><strong><span class="style12">Busca por Valor do Imóvel</span> </strong>
                      <blockquote>
                        <?php include ("includes/templates/inc-pricesearch.php"); ?>
                      </blockquote></td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td align="center" valign="middle"> </td>
              </tr>
              <tr>
                <td align="center" valign="middle"> </td>
              </tr>
            </table></td>
          <td valign="top" bgcolor="#FFFFFF"> 
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td> </td>
                <td align="left" valign="top"> </td>
                <td> </td>
              </tr>
              <tr> 
                <td width="20"> </td>
                <td width="800" align="left" valign="top"><?php
  if ( 
  $cgi->getValue ( "op" ) == "search" || 
  $cgi->getValue ( "op" ) == "mi"  || 
  $cgi->getValue ( "sp" ) == "y"|| 
  $cgi->getValue ( "op" ) == "SendInformationRequest" )
  { include "search_.php"; }
  else { ?>
                  <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td> </td>
                  </tr>
                  <tr>
                    <td><div align="justify">
                      <object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="500" height="300">
                        <param name="movie" value="images/teste2.swf">
  <param name="quality" value="high">
  <param name="wmode" value="opaque">
  <param name="swfversion" value="9.0.45.0">
  <!-- Esta tag param solicita que os usuários com o Flash Player 6.0 r65 e versões posteriores baixem a versão mais recente do Flash Player. Exclua-o se você não deseja que os usuários vejam o prompt. -->
  <param name="expressinstall" value="Scripts/expressInstall.swf">
  <!-- A tag object a seguir aplica-se a navegadores que não sejam o IE. Portanto, oculte-a do IE usando o IECC. -->
  <!--[if !IE]>-->
  <object type="application/x-shockwave-flash" data="images/teste2.swf" width="500" height="300">
    <!--<![endif]-->
    <param name="quality" value="high">
    <param name="wmode" value="opaque">
    <param name="swfversion" value="9.0.45.0">
    <param name="expressinstall" value="Scripts/expressInstall.swf">
    <!-- O navegador exibe o seguinte conteúdo alternativo para usuários que tenham o Flash Player 6.0 e versões anteriores. -->
    <div>
      <h4>O conteúdo desta página requer uma versão mais recente do Adobe Flash Player.</h4>
      <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Obter Adobe Flash player" width="112" height="33" /></a></p>
    </div>
    <!--[if !IE]>-->
  </object>
  <!--<![endif]-->
</object>
                    </div></td>
                  </tr>
                  <tr>
                    <td> </td>
                  </tr>
                  <tr>
                      <td height="1" background="images/lista_im.gif"></td>
                    </tr>
                  <tr>
                    <td> </td>
                  </tr>
                  <tr>
                    <td height="30" align="left" valign="middle" bgcolor="#0058A9"><img src="includes/images/destaque.gif" width="189" height="30"></td>
                  </tr>
                  <tr>
                    <td> </td>
                  </tr>
                  <tr>
                    <td> </td>
                  </tr>
                </table>
                  <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td align="center" valign="middle"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                        <tr align="center" valign="middle">
                          <td><?PHP include "includes/tools/random-property.php"; ?></td>
                          <td><?PHP include "includes/tools/random-property.php"; ?></td>
                          <td><?PHP include "includes/tools/random-property.php"; ?></td>
                        </tr>
                      </table></td>
                    </tr>
                  </table>  
                  <p>        <?php }
?>         
                </p>  </td><td width="10"> </td>
              </tr>
            </table></td>
        </tr>
        <tr> 
          <td bgcolor="#FFFFFF"> </td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td height="35" align="center" valign="middle" bgcolor="#0058A9">
      <table width="980" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="218"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td align="right" valign="middle"><img src="includes/images/contato.gif" width="189" height="35"></td>
            </tr>
            <tr>
              <td align="left" valign="middle"> <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="26%"> </td>
                  <td width="74%" align="left" valign="middle"><span class="style12" style="color:#fff">Fone: <br>
                        (11) 0000-0000</span></td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td align="left" valign="middle"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="26%"> </td>
                  <td width="74%" align="left" valign="middle"><span class="style12" style="color:#fff">Fax: <br>
                        (11) 0000-0000</span></td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td align="left" valign="middle"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="26%"> </td>
                  <td width="74%" align="left" valign="middle"> </td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td align="left" valign="middle"> </td>
            </tr>
          </table></td>
          <td width="762" align="center" valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height="25"> </td>
            </tr>
            <tr>
                <td align="center" valign="middle"><p><span class="baseline">© 
                    Copyright <?php echo date("Y"); ?> M&F Design.</span> </p>
                  <p> </p></td>
            </tr>
          </table></td>
        </tr>
      </table></td>
  </tr>
</table>
&lt;script type="text/javascript">
swfobject.registerObject("FlashID");
</script>
</body>
</html>

inc-searchbox.php
<link href="../../images/style.css" rel="stylesheet" type="text/css">
<?php
require ( "includes/config.php" );
require ( "includes/CGI.php" );
require ( "includes/SQL.php" );

$cgi = new CGI ();
$sql = new SQL ( $DBusername, $DBpassword, $server, $database );

if ( ! $sql->isConnected () )
{
  die ( $DatabaseError );
}

require ( "includes/CSQL.php" ); 
require ( "includes/lang/" . $language_pack . "/index.php" );

?>

<style type="text/css">
<!--
.style1 {
	color: #FFFFFF;
	font-weight: bold;
}
.style2 {color: #FFFFFF}
-->
</style>
<form method="get" action="<?php echo "$template_page_name"; ?>">
<input name="op" type="hidden" value="search" />
<table width="233" height="297" border="0" align="center"  cellpadding="2" cellspacing="2">
<?php if($display_search_types == "Y") { ?>
<tr>
<td width="87" height="25"><p align="right" class="menu style1" style="color:#000">Tipo:</p></td>
<td width="128"><p>
<select name="pt" size="1" style="height: 18px; width:125px;">
<option value="" selected="selected"><?php echo FORM_SELECT_ALL_TYPES; ?></option>
<?PHP 

    $rows = $sql->execute ( "SELECT * FROM " . $propertytypes_table .
        " ORDER BY propertytype ASC", SQL_RETURN_ASSOC );

    for ( $i = 0; $i < sizeof ( $rows ); ++$i )
    {
      $row = $rows [ $i ];
      
      ?>
<option value="<?php echo $cgi->htmlEncode ( $row [ "id" ] ); ?>">
<?php
      echo $cgi->htmlEncode ( $row [ "propertytype" ] ); ?>
</option>
<?php
    }

?>
</select>
</p></td>
</tr>
<?php }
 if($display_search_max_price == "Y") { 
?>
<tr>
<td class="b2" height="25"><p align="right" class="style1" style="color:#000">Menor Valor:</p></td>
<td><p>
<select name="pp_max" style="height: 18px; width:125px;">
<?php if (($display_sale) == "Y"){ ?>
<option value="45000" selected="selected"><?php echo CURRENCY; ?> 45.000,00</option>
<option value="65000"><?php echo CURRENCY; ?> 65.000,00</option>
<option value="75000"><?php echo CURRENCY; ?> 75.000,00</option>
<option value="100000"><?php echo CURRENCY; ?> 100.000,00</option>
<option value="125000"><?php echo CURRENCY; ?> 125.000,00</option>
<option value="150000"><?php echo CURRENCY; ?> 150.000,00</option>
<option value="175000"><?php echo CURRENCY; ?> 175.000,00</option>
<option value="200000"><?php echo CURRENCY; ?> 200.000,00</option>
<option value="300000"><?php echo CURRENCY; ?> 300.000,00</option>
<option value="400000"><?php echo CURRENCY; ?> 400.000,00</option>
<option value="500000"><?php echo CURRENCY; ?> 500.000,00</option>
<option value="600000"><?php echo CURRENCY; ?> 600.000,00</option>
<option value="700000"><?php echo CURRENCY; ?> 700.000,00</option>
<option value="800000"><?php echo CURRENCY; ?> 800.000,00</option>
<option value="900000"><?php echo CURRENCY; ?> 900.000,00</option>
<option value="1000000"><?php echo CURRENCY; ?> 1.000,000,00</option>
<option value="2000000"><?php echo CURRENCY; ?> 2.000,000,00</option>
<?php } if (($display_rental) == "Y"){ ?>
<option value=""><?php echo FORM_DISPLAY_RENTAL_SELECT; ?></option>
<option value="200"><?php echo CURRENCY; ?> 200,00</option>
<option value="300"><?php echo CURRENCY; ?> 300,00</option>
<option value="400"><?php echo CURRENCY; ?> 400,00</option>
<option value="500"><?php echo CURRENCY; ?> 500,00</option>
<option value="750"><?php echo CURRENCY; ?> 750,00</option>
<?php } ?>
</select>
</p></td>
</tr>
<tr>
<td height="25"><p align="right" class="copyright style2"><strong style="color:#000">Maior  Valor:</strong></p></td>
<td><p>
<select name="pp_min" style="height: 18px; width:125px;">
<?php if (($display_sale) == "Y"){ ?>
<option value="100"><?php echo CURRENCY; ?> 100,00</option>
<option value="125"><?php echo CURRENCY; ?> 125,00</option>
<option value="150"><?php echo CURRENCY; ?> 150,00</option>
<option value="175"><?php echo CURRENCY; ?> 175,00</option>
<option value="200"><?php echo CURRENCY; ?> 200,00</option>
<option value="300"><?php echo CURRENCY; ?> 300,00</option>
<option value="400"><?php echo CURRENCY; ?> 400,00</option>
<option value="500"><?php echo CURRENCY; ?> 500,00</option>
<option value="600"><?php echo CURRENCY; ?> 600,00</option>
<option value="700"><?php echo CURRENCY; ?> 700,00</option>
<option value="800"><?php echo CURRENCY; ?> 800,00</option>
<option value="900"><?php echo CURRENCY; ?> 900,00</option>
<option value="1000"><?php echo CURRENCY; ?> 1.000,00</option>
<option value="2000" selected="selected"><?php echo CURRENCY; ?> 2.000,00</option>
<?php } if (($display_rental) == "Y"){ ?>
<option value=""><?php echo FORM_DISPLAY_RENTAL_SELECT; ?></option>
<option value="200"><?php echo CURRENCY; ?> 200,00</option>
<option value="300"><?php echo CURRENCY; ?> 300,00</option>
<option value="400"><?php echo CURRENCY; ?> 400,00</option>
<option value="500"><?php echo CURRENCY; ?> 500,00</option>
<option value="750"><?php echo CURRENCY; ?> 750,00</option>
<option value="1000"><?php echo CURRENCY; ?> 1.000,00</option>
<option value="1500"><?php echo CURRENCY; ?> 1.500,00</option>
<?php } ?>
</select>
</p></td>
</tr>
<?php }  if($display_search_bedrooms == "Y") { ?>
<tr>
<td height="25"><p align="right" class="style2 copyright"><strong style="color:#000"> Quartos:</strong></p></td>
<td><p>
<select name="pb" style="height: 18px; width:125px;">
<option value="0" selected="selected"><?php echo FORM_NO_PREFERENCE; ?></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</p></td>
</tr>
<?php }  if($display_search_locations == "Y") { ?>
<tr>
<td height="25"><b>Estado:</b>:</strong></td>
<td><script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/cbox.js"></script><p>
  <select name="categoria">
    <option value="0">Escolha um Estado</option>
    <?php
include("include/connect_data_base.php");

$sql_cat=mysql_query("SELECT * FROM estado ORDER BY descricao ASC") or die(mysql_error());
while($result_sql_cat = mysql_fetch_object($sql_cat)){
echo '<option value="'.$result_sql_cat->id.'">'.$result_sql_cat->descricao.'</option>';
}
?>
    <!--  -->
  </select>
  </p>
</td>
</tr>
<?php } ?>
<?php 
if (($display_rental & $display_sale) == "Y"){
echo "<TR><TD></TD><TD><p><input name=\"po\" type=\"radio\" value=\"S\"><font color=\"#000000\" face=\"Arial\" size=\"2\">Vendas</font><br>
<input name=\"po\" type=\"radio\" value=\"R\"><font color=\"#000000\" face=\"Arial\" size=\"2\">Aluguel</font><br></p></TD></TR>";
}
elseif (($display_rental) == "Y"){
echo "<TR><TD></TD><TD><p>
<input name=\"po\" type=\"hidden\" value=\"R\"></p></TD></TR>";
}
elseif (($display_sale) == "Y"){
echo "<TR><TD></TD><TD><p>
<input name=\"po\" type=\"hidden\" value=\"S\"></p></TD></TR>";
}
?>
<tr>
<td height="38"><b>Cidade:</b></td>
<td>
  <select name="cidade">
    <option value="0" disabled="disabled">Escolha um Estado Primeiro</option>
  </select>
</td>
</tr>
<tr>
  <td height="38"><b>Bairro</b></td>
  <td><select name="bairro">
    <option value="0" disabled="disabled">Escolha uma Cidade Primeiro</option>
  </select></td>
</tr>
<tr>
  <td height="38"></td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td height="38"></td>
  <td><input name="input" type="image" src="<?php print "$LanguageFolder/$language_pack"; ?>/buttons/button-search.gif" /></td>
</tr>
</table>
</form>


inc-locations.php
<?php
require ( "includes/config.php" );
require ( "includes/CGI.php" );
require ( "includes/SQL.php" );

$cgi = new CGI ();
$sql = new SQL ( $DBusername, $DBpassword, $server, $database );

if ( ! $sql->isConnected () )
{
  die ( $DatabaseError );
}

require ( "includes/CSQL.php" ); 
require ( "includes/lang/" . $language_pack . "/index.php" );

// Get the property locations from the database and display them in alpha order
    {        
    $rows = $sql->execute ( "SELECT * FROM " . $bairro_table .
      " ORDER BY descricao ASC", SQL_RETURN_ASSOC );

    $num = sizeof ( $rows );      
      for ( $i = 0; $i < $num; ++$i )
      {
        $id = $rows [ $i ] [ "codigo" ];
        $propertylocation = $rows [ $i ] [ "descricao" ];
  echo "<img src=\"includes/images/arrow_blue.gif\" width=\"10\" height=\"13\">  <a href=\"$template_page_name?op=search&pl=$id\" style=\"color:#000\">$propertylocation</a><br>";        
 }
  }
  
?>
inc-locations2.php
<?php
require ( "includes/config.php" );
require ( "includes/CGI.php" );
require ( "includes/SQL.php" );

$cgi = new CGI ();
$sql = new SQL ( $DBusername, $DBpassword, $server, $database );

if ( ! $sql->isConnected () )
{
  die ( $DatabaseError );
}

require ( "includes/CSQL.php" ); 
require ( "includes/lang/" . $language_pack . "/index.php" );

// Get the property locations from the database and display them in alpha order
    {        
    $rows = $sql->execute ( "SELECT * FROM " . $cidade_table .
      " ORDER BY descricao ASC", SQL_RETURN_ASSOC );

    $num = sizeof ( $rows );      
      for ( $i = 0; $i < $num; ++$i )
      {
        $id = $rows [ $i ] [ "codigo" ];
        $propertylocation = $rows [ $i ] [ "descricao" ];
  echo "<img src=\"includes/images/arrow_blue.gif\" width=\"10\" height=\"13\">  <a href=\"$template_page_name?op=search&pl=$id\" style=\"color:#000\">$propertylocation</a><br>";        
 }
  }
  
?>
layout_view.php
<?php
   
  $layoutId = $cgi->getValue ( "id" );

  $rows = $sql->execute ( "SELECT * FROM " . $property_table . " WHERE id=" .
    $sql->quote ( $layoutId ) . " AND propertyshow=1 LIMIT 1",
    SQL_RETURN_ASSOC );

  $row = $rows [ 0 ];

  $Price = number_format ( $row [ 'propertyprice' ], 2, ",", "." ); 

  $sql->execute ( "UPDATE " . $property_table .
      " SET propertyviews=(propertyviews + 1) WHERE id=" .
      $sql->quote ( $layoutId ) . " LIMIT 1" );

$ThumbPhotoWidth = "100";
$ThumbPhotoHeight = "80";
?>

<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0"> 
<tr valign="top">
  <td colspan="2" valign="top"><table width="100%" border="0"  align="center" cellpadding="0" cellspacing="0" class="lvp_top_nav_menu_bg">
    <tr valign="middle">
      <td>  <?php echo LV_PROPERTY_REF; ?> <strong><?php echo $row [ "propertyref" ]; ?></strong> - <?php echo $row [ "propertyaddress" ]; ?> - <?php echo $_GET [ "pl" ]; ?> - Cep: <?php echo $row [ "propertypostcode" ]; ?></td>
      <td align="right"> <a href="?sp=y&id=<?php echo $row [ "id" ]; ?>"><img src="includes/lang/<?php print "$language_pack"; ?>/buttons/button-view-photos.gif" title="Ver Fotos" border="0" /></a> <a href="javascript:history.go(-1)"><img src="includes/lang/<?php print "$language_pack"; ?>/buttons/button-back.gif" title="Voltar" border="0" /></a></td>
    </tr>
  </table></td>
  </tr>
<tr valign="top">
<td width="48%" valign="top"><?php   if ( ! $row [ 'propertyphoto1' ] )
  {
    ?>
  <img src="<?php echo $ImageURL; ?>nopropertyimage.jpg" border="0" />
  
  <?php
  }
  else
  {
    ?>
  <table cellpadding="0" cellspacing="1">
    <tr>
      <td width="300" height="300" align="center" valign="top"><img src="<?php echo $ImageURL; ?><?php echo $row [ "propertyphoto1" ]; ?>" name="large" hspace="10"  border="0" align="left" id="large" />
          </td>
    </tr>
    <tr>
      <td width="300" align="center" valign="top"><table cellpadding="0" cellspacing="2">
          <tr>
            <td valign="middle" align="center"><?php if ($row [ 'propertyphoto1' ] ) { echo "<img src=\"$ImageURL$row[propertyphoto1]\" width=\"$ThumbPhotoWidth\" height=\"$ThumbPhotoHeight\" border=\"0\" onmousedown=\"document.images['large'].src='$ImageURL$row[propertyphoto1]'\">";} ?>            </td>
            <td valign="middle" align="center"><?php if ($row [ 'propertyphoto2' ] ) { echo "<img src=\"$ImageURL$row[propertyphoto2]\" width=\"$ThumbPhotoWidth\" height=\"$ThumbPhotoHeight\" border=\"0\" onmousedown=\"document.images['large'].src='$ImageURL$row[propertyphoto2]'\">";} ?></td>
            <td valign="middle" align="center"><?php if ($row [ 'propertyphoto3' ] ) { echo "<img src=\"$ImageURL$row[propertyphoto3]\" width=\"$ThumbPhotoWidth\" height=\"$ThumbPhotoHeight\" border=\"0\" onmousedown=\"document.images['large'].src='$ImageURL$row[propertyphoto3]'\">";} ?></td>
          </tr>
          <tr>
            <td valign="middle" align="center"><?php if ($row [ 'propertyphoto4' ] ) { echo "<img src=\"$ImageURL$row[propertyphoto4]\" width=\"$ThumbPhotoWidth\" height=\"$ThumbPhotoHeight\" border=\"0\" onmousedown=\"document.images['large'].src='$ImageURL$row[propertyphoto4]'\">";} ?>            </td>
            <td valign="middle" align="center"><?php if ($row [ 'propertyphoto5' ] ) { echo "<img src=\"$ImageURL$row[propertyphoto5]\" width=\"$ThumbPhotoWidth\" height=\"$ThumbPhotoHeight\" border=\"0\" onmousedown=\"document.images['large'].src='$ImageURL$row[propertyphoto5]'\">";} ?>            </td>
            <td valign="middle" align="center"><?php if ($row [ 'propertyphoto6' ] ) { echo "<img src=\"$ImageURL$row[propertyphoto6]\" width=\"$ThumbPhotoWidth\" height=\"$ThumbPhotoHeight\" border=\"0\" onmousedown=\"document.images['large'].src='$ImageURL$row[propertyphoto6]'\">";} ?>            </td>
          </tr>
          <tr>
            <td valign="middle" align="center"><?php if ($row [ 'propertyphoto7' ] ) { echo "<img src=\"$ImageURL$row[propertyphoto7]\" width=\"$ThumbPhotoWidth\" height=\"$ThumbPhotoHeight\" border=\"0\" onmousedown=\"document.images['large'].src='$ImageURL$row[propertyphoto7]'\">";} ?>            </td>
            <td valign="middle" align="center"><?php if ($row [ 'propertyphoto8' ] ) { echo "<img src=\"$ImageURL$row[propertyphoto8]\" width=\"$ThumbPhotoWidth\" height=\"$ThumbPhotoHeight\" border=\"0\" onmousedown=\"document.images['large'].src='$ImageURL$row[propertyphoto8]'\">";} ?>            </td>
            <td valign="middle" align="center"><?php if ($row [ 'propertyphoto9' ] ) { echo "<img src=\"$ImageURL$row[propertyphoto9]\" width=\"$ThumbPhotoWidth\" height=\"$ThumbPhotoHeight\" border=\"0\" onmousedown=\"document.images['large'].src='$ImageURL$row[propertyphoto9]'\">";} ?>            </td>
          </tr>
          <tr>
            <td valign="middle" align="center"><?php if ($row [ 'propertyphoto10' ] ) { echo "<img src=\"$ImageURL$row[propertyphoto10]\" width=\"$ThumbPhotoWidth\" height=\"$ThumbPhotoHeight\" border=\"0\" onmousedown=\"document.images['large'].src='$ImageURL$row[propertyphoto10]'\">";} ?>            </td>
            <td valign="middle" align="center"></td>
            <td valign="middle" align="center"></td>
          </tr>
      </table></td>
    </tr>
  </table> <?php } ?> </td> 
<td width="52%" align="left" valign="top"><p><?php echo $row [ "shortdescription" ]; ?></p>
<table width="100%" border="0" cellspacing="0" cellpadding="5">
  <tr>
    <td align="left" valign="top">
<p><strong>Valor:</strong> <strong><?php echo CURRENCY; ?> <?php echo "$Price"; ?></strong></p>
<p>
  <?php
  if ( $row [ 'propertybedrooms' ] )
  {
    echo " $row[propertybedrooms] - Quartos<br>";
  }
    if ( $row [ 'propertybathrooms' ] )
  {
    echo "$row[propertybathrooms] - Banheiros";
  }	
	?>
</p>
<?php

  $_features = $sql->execute ( "SELECT description FROM " .
      $features_table . " INNER JOIN " . $propertyfeatures_table .
      " ON (id=feature_id) WHERE property_id=" .
      $sql->quote ( $layoutId ),
      SQL_RETURN_ASSOC );


  $features = array ();

  if ( $row [ 'propertyyearbuilt' ] )
  {
    $features [] = "Construído em $row[propertyyearbuilt]";
  }

  if ( $row [ 'propertylivingarea' ] )
  {
    $features [] = "$row[propertylivingarea] Área Construída";
  }

  if ( $row [ 'propertyplotsize' ] )
  {
    $features [] = "$row[propertyplotsize] Área Total";
  }

  for ( $i = 0; $i < sizeof ( $_features ); ++$i )
  {
    $features [] = $cgi->htmlEncode ( $_features [ $i ] [ "description" ] );
  }

  for ( $i = 0; $i < sizeof ( $features ); ++$i )
  {
?>
  <p><?php echo $cgi->htmlEncode ( $features [ $i ] ); ?></p>
  <?php
  }

?></td>
    </tr>
</table></td>
</tr>
<tr valign="top">
<td colspan="2" valign="top">
<p align="left"><?php echo nl2br($row [ "longdescription" ]); ?></p></td>
</tr>
</table>
<table width="540" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr align="center" valign="middle">
    <td width="150"><a href="#CONTACT"><img src="includes/images/link-requestinformation.gif" width="150" height="40" border="0"></a></td>
    <td width="20"> </td>
    <td width="174"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td align="center" valign="middle"><?php $MapLinkUrl = str_replace("XXXXXX", "$row[propertypostcode]", "$property_map_url"); if ($row [ 'propertypostcode' ] ) { print "<td></td><td><a href=\"$MapLinkUrl\" target=\"new\"><img src=\"includes/images/link-map.gif\" border=\"0\"/></a></td>";} ?></td>
      </tr>
    </table></td>
    <td width="20"> </td>
    <td width="176"><a href="includes/templates/printfactsheet.php?id=<?php echo $row [ "id" ]; ?>" target="_blank"><img src="includes/images/link-print.gif" width="176" height="40" border="0"></a></td>
  </tr>
</table>
<p> </p>
layout_results.php
<?php

  $Price = number_format ($row [ 'propertyprice' ], 2, ",", "."); 

?>
<table width="100%" align="center" class="lrp_bg"> 
    <tr valign="middle"> 
  <td colspan="2" valign="middle" align="left"> 
  <p> <font  size="-1"><b><?php echo $row [ "propertyaddress" ]; ?>
  - <?php echo $cgi->htmlEncode ( $row [ "codigo" ] ); ?></b></font></p></td> 
    <td valign="middle" align="right"><p class="propertystatus"><?php
  echo strtoupper ( $cgi->htmlEncode ( $row [ "propertystatus" ] ) );
          ?> </p></td>
</tr> 
    <tr> 
      <td colspan="3" bgcolor="#FFFFFF"> 
       <table width="100%" cellpadding="3" cellspacing="1"> 
        <tr> 
          <td><p align="center">
<?php

  if ( ! $row [ "propertyphoto1" ] )
  {
    ?><img src="<?php echo $ImageURL; ?>nopropertyimage.jpg" height="<?php
    echo $max_thumb_image_height; ?>" width="<?php echo $max_thumb_image_width; ?>"
      border="0" /><?php
  }
  else
  {
    ?><a href="?op=mi&id=<?php echo $row [ "id" ]; ?>&pl=<?php echo $row [ "propertylocation" ]; ?>"><img src="<?php
    echo $ImageURL; ?><?php echo $row [ "propertyphoto1" ]; ?>" height="<?php
    echo $max_thumb_image_height; ?>" width="<?php echo $max_thumb_image_width; ?>"
      border="0" alt="<?php
      echo $row [ "propertyaddress" ]; ?>, <?php
      echo $row [ "propertylocation" ]; ?>" title="<?php
      echo $row [ "propertyaddress" ]; ?>, <?php
      echo $row [ "propertylocation" ]; ?>" /></a><?php
  }

  ?></p></td>
          <td valign="top" align="left" width="100%">
   <table width="100%" cellpadding="1" cellspacing="1">
    <tr>
      <td>
    <p><?php echo LR_PROPERTY_TYPE; ?> <b><?php echo $row [ "propertytype" ]; ?></b></p></td>
      <td>
    <p><?php echo LR_PROPERTY_PRICE; ?> <b><?php echo CURRENCY, $Price; ?></b></p></td>
   </tr>
    <tr>
      <td>
    <p><?php echo LR_PROPERTY_REF; ?> <b><?php echo $row [ "propertyref" ]; ?></b></p></td>
      <td>
      <p>
    <?php if ($row [ "propertybedrooms" ] == "0") { echo "";} else { ?> 	
	<?php echo LR_NUMBER_OF_BEDROOMS; ?> <b><?php echo $row [ "propertybedrooms" ]; ?></b>
    <?php } ?></p></td>
   </tr>
   </table>
           <p>
         <?php echo $row [ "shortdescription" ]; ?></p>
         <p align="right"><a href="?op=mi&id=<?php echo $row [ "id" ];
         ?>&pl=<?php echo $row [ "propertylocation" ]; ?>"><img src="<?php print "$LanguageFolder/$language_pack"; ?>/buttons/button-moreinformation.gif" title="Veja mais detalhes" border="0" /></a></p></td> 
       </tr> 
    </table></td> 
</tr> 
</table>
<br />
<br />
search_.php
<?php

require ( "includes/config.php" );
require ( "includes/CGI.php" );
require ( "includes/SQL.php" );

$cgi = new CGI ();
$sql = new SQL ( $DBusername, $DBpassword, $server, $database );

if ( ! $sql->isConnected () )
{
  die ( $DatabaseError );
}

require ( "includes/CSQL.php" ); 
require ( "includes/lang/" . $language_pack . "/index.php" );

?>
<!--
//  comment this out, allows you to use your own stylesheet with propertymax pro 
<link rel="stylesheet" href="includes/lang/<?php print "$language_pack"; ?>/style.css" />
-->
&lt;script language="JavaScript" type="text/javascript">
<!-- Begin
var submitcount=0;
function reset() {
document.emailform.name.value="";
document.emailform.email.value="";
document.emailform.address.value="";
}

function checkFields() {                    
if (                                    
 (document.emailform.name.value=="") ||
 (document.emailform.email.value=="")  ||
 (document.emailform.address.value==""))  
   {
   alert("<?php echo GENERAL_FORM_POPUP_ERROR_MESSAGE; ?>");
   return false;
   }
}
//  End --></script>
<?php
  
  if ( $cgi->getValue ( "op" ) == "SendInformationRequest" )
  {
// Contact Form Spam Check for Website URl's which should not be there
$SpamErrorMessage = "<p align=\"center\"><font color=\"red\">Website URLs are not permitted in the request form.</font></b></p>";
if (preg_match("/http/", "" . $cgi->getValue ( "name" ) . "")) {echo "$SpamErrorMessage"; exit();} 
if (preg_match("/http/", "" . $cgi->getValue ( "email" ) . "")) {echo "$SpamErrorMessage"; exit();} 
if (preg_match("/http/", "" . $cgi->getValue ( "telephone" ) . "")) {echo "$SpamErrorMessage"; exit();} 
if (preg_match("/http/", "" . $cgi->getValue ( "address" ) . "")) {echo "$SpamErrorMessage"; exit();} 
  
    $yoursubject = "".EMAIL_SUBJECT." Cod. " . $cgi->getValue ( "propertyref" );
    $emailtext = "
-----------------------------------------------------------------------------
   ".EMAIL_TEXT_TITLE."
-----------------------------------------------------------------------------
".EMAIL_TEXT_BODY."

".EMAIL_PD."
".EMAIL_PROEPRTY_REF."      " . $cgi->getValue ( "propertyref" ) . "
".EMAIL_PROPERTY_ADDRESS."  " . $cgi->getValue ( "propertyaddress" ) . "
".EMAIL_PROPERTY_PRICE."    ".CURRENCY.""  . $cgi->getValue ( "propertyprice" ) . "

".EMAIL_RD."
".EMAIL_NAME."    " . $cgi->getValue ( "name" ) . "
".EMAIL_EMAIL_ADDRESS."   " . $cgi->getValue ( "email" ) . "
".EMAIL_TELEPHONE."   " . $cgi->getValue ( "telephone" ) . "

" . $cgi->getValue ( "address" ) . "

________________________________
".EMAIL_FOOTER."
";

    $yoursubject = stripslashes ( $yoursubject ); 
    $emailtext = stripslashes ( $emailtext );
    @mail ( $cgi->getValue ( "adminemailaddress" ), $yoursubject, $emailtext,
        "From: " . $cgi->getValue ( "email" ) ); 
?>
<br />
<br />
<br />
<p align="center"><?php echo EMAIL_SUCCESS_MESSAGE; ?></p>
<br />
<p align="center">[<a href="?op=search&po=S"><?php echo FORM_VIEW_ALL_SALE_PROPERTIES; ?></a>]</p>
<br />
<br />
<?php

  } 

  // view more information about the property if requested
  if ( $cgi->getValue ( "op" ) == "mi" )
  {
  // Start of Display Output
    require ( "includes/templates/layout_view.php" );
  // End of Display output


    $arows = $sql->execute ( "SELECT * FROM " . $admin_table . " LIMIT 1",
        SQL_RETURN_ASSOC );
    $arow = $arows [ 0 ];

  
?>
<table width="100%"  align="center" class="lvp_top_nav_menu_bg">
<tr valign="top">
<td><p><?php echo LV_MORE_INFORMATION_TITLE; ?></p></td>
</tr>
</table>
<a name="CONTACT" id="CONTACT"></a>
<p align="center"><?php echo LV_MORE_INFORMATION_TEXT; ?></p>
<br />
<table width="85%" align="center" cellpadding="10">
<tr>
<td valign="top"><p><strong><?php echo $cgi->htmlEncode ( $arow [ "adminbusinessname" ] ); ?></strong><br />
<?php echo $cgi->htmlEncode ( $arow [ "adminaddress" ] ); ?><br />
<?php echo $cgi->htmlEncode ( $arow [ "admintown" ] ); ?><br />
<?php echo $cgi->htmlEncode ( $arow [ "admincounty" ] ); ?><br />
<?php echo $cgi->htmlEncode ( $arow [ "adminpostcode" ] ); ?></p>
<p>Tel: <?php echo $cgi->htmlEncode ( $arow [ "admintelephone" ] ); ?><br />
Fax: <?php echo $cgi->htmlEncode ( $arow [ "adminfax" ] ); ?></p></td>
<td><form method="post" name="emailform" id="emailform" onsubmit="return checkFields()">
<input name="op" type="hidden" value="SendInformationRequest" />
<input name="propertyref" type="hidden" value="<?php echo $cgi->htmlEncode ( $row [ "propertyref" ] ); ?>" />
<input name="propertyaddress" type="hidden" value="<?php echo $cgi->htmlEncode ( $row [ "propertyaddress" ] ); ?>" />
<input name="propertylocation" type="hidden" value="<?php echo $cgi->htmlEncode ( $row [ "propertylocation" ] ); ?>" />
<input name="propertyprice" type="hidden" value="<?php echo $cgi->htmlEncode ( $row [ "propertyprice" ] ); ?>" />
<input name="adminemailaddress" type="hidden" value="<?php
                    echo $cgi->htmlEncode ( $arow [ "adminemailaddress" ] ); ?>" />
<table cellpadding="1" cellspacing="1">
<tr>
<td align="right"><p><?php echo LV_NAME; ?> </p></td>
<td><input type="text" name="name" size="35"
                      maxlength="100" /></td>
</tr>
<tr>
<td align="right"><p><?php echo LV_EMAIL; ?> </p></td>
<td><input type="text" name="email" size="35"
                      maxlength="100" /></td>
</tr>
<tr>
<td align="right"><p><?php echo LV_TELEPHONE; ?> </p></td>
<td><input type="text" name="telephone" size="35"
                      maxlength="100" /></td>
</tr>
<tr>
<td align="right" valign="top"><p><?php echo LV_ADDRESS; ?> </p></td>
<td><textarea name="address" rows="5" cols="35"></textarea></td>
</tr>
<tr>
<td align="right" valign="top"> </td>
<td><input name="" type="image" src="<?php print "$LanguageFolder/$language_pack"; ?>/buttons/button-send-request.gif" /></td>
</tr>
</table>
<p> </p>
</form></td>
</tr>
</table>
<?php
  }
  else if ( $cgi->getValue ( "op" ) == "search" )
  {
    $pt = $cgi->getValue ( "pt" );
    $pp = $cgi->getValue ( "pp" );
    $pb = $cgi->getValue ( "pb" );
    $pl = $cgi->getValue ( "pl" );
    $po = $cgi->getValue ( "po" );
    $pp_min = $cgi->getValue ( "pp_min" );
    $pp_max = $cgi->getValue ( "pp_max" );
    $query = "
      SELECT
        p.id                AS id,
        p.propertyoption    AS propertyoption,
        p.propertyprice     AS propertyprice,
        p.propertyaddress   AS propertyaddress,
        pl.propertylocation AS propertylocation,
        ps.propertystatus   AS propertystatus,
        pt.propertytype     AS propertytype,
        p.propertyref       AS propertyref,
        p.propertybedrooms  AS propertybedrooms,
        p.propertyphoto1    AS propertyphoto1,
        p.propertyphoto2    AS propertyphoto2,
        p.propertyphoto3    AS propertyphoto3,
        p.propertyphoto4    AS propertyphoto4,
        p.shortdescription  AS shortdescription,
        p.longdescription   AS longdescription,
		p.virtualtour   AS virtualtour
      FROM
        " . $property_table . " p
        INNER JOIN
        " . $propertytypes_table . " pt ON (p.propertytype=pt.id)
        INNER JOIN
        " . $propertylocations_table . " pl ON (p.propertylocation=pl.id)
        INNER JOIN
        " . $propertystatus_table . " ps ON (p.propertystatus=ps.id)
      WHERE
        p.propertyshow=1
      ";

    if ( $pt != "" )
      $query .= " AND p.propertytype=" . $sql->quote ( $pt );

    if ( $pp_min != "" )
      $query .= " AND p.propertyprice>=" . $sql->quote ( $pp_min );

    if ( $pp_max != "" )
      $query .= " AND p.propertyprice<=" . $sql->quote ( $pp_max );
     
    if ( $pb != "" )
      $query .= " AND p.propertybedrooms>=" . $sql->quote ( $pb );

    if ( $pl != "" )
      $query .= " AND p.propertylocation=" . $sql->quote ( $pl );

     if ( $po != "" )
      $query .= " AND p.propertyoption=" . $sql->quote ( $po );
    // set the query ordering
    if ( isset ( $property_search_order ) && $property_search_order != "" )
      $query .= "ORDER BY p." . $property_search_order . " " .
           ( "a" == strtolower ( substr ( $property_search_ordering, 0, 1 ) ) ?
             "ASC" : "DESC" );
    
    $results = $sql->execute ( $query, SQL_RETURN_ASSOC );
    
    $total_results = sizeof ( $results );

    if ( $total_results == 0 )
    {
      ?>
<br />
<br />
<p align="center"><?php echo GENERAL_NO_PROPERTIES_FOUND; ?></p>
<br />
<br />
<br />
<?php

    }
if ( $total_results  >0 ) {    
    $total_pages = ceil ( $total_results / $property_search_limit ); //total number of pages

    $page = $cgi->getValue ( "page" );

    if ( ! $page )
      $page = 1;
      
    $offset = ( $page - 1 ) * $property_search_limit; //starting number for displaying results out of DB 
    $max = $offset + $property_search_limit;
    $max = ( $max > $total_results ? $total_results : $max );
    
?>
<p align="center"><?php echo GENERAL_PROPERTIES_FOUND; ?></p>
<br />
<?php
 
    for ( $l = $offset; $l < $max; ++$l )
    { 
      $row = $results [ $l ];
      
      // Start of Display Output
      require ( "includes/templates/layout_results.php" );
      // End of Display output
    }  

    ?>
<div align="center">
<p><?php echo GENERAL_PAGE; ?> -
<?php
    
    if ( $page != 1 )
    { 
    ?>
<a href="<?php echo $_SERVER [ 'PHP_SELF' ]; ?>?op=search&page=1&po=<?php echo $po; ?>&pt=<?php echo $pt; ?>&pp=<?php echo $pp; ?>&pb=<?php echo $pb; ?>&pl=<?php echo $pl; ?>&pp_min=<?php echo $pp_min; ?>&pp_max=<?php echo $pp_max; ?>"><< Voltar </a>  - 
<?php
      
      $prevpage = $page - 1; 
    }

    $to = ( $page < $total_pages - 2 ? $page + 3 : $total_pages );
    $from = ( $page >= 1 && $page <= 3 ? 1 : $page - 3 );

    for ( $i = $from; $i <= $to; ++$i ) 
    { 
      if ( $i == $total_results )
        $to = $total_results; 
        
      if ( $i != $page )
      { 
        ?>
<a href="?op=search&showold=yes&page=<?php echo $i; ?>&po=<?php echo $po; ?>&pt=<?php echo $pt; ?>&pp=<?php echo $pp; ?>&pb=<?php echo $pb; ?>&pl=<?php echo $pl; ?>&pp_min=<?php echo $pp_min; ?>&pp_max=<?php echo $pp_max; ?>"><?php echo $i; ?></a>
<?php
      } 
      else 
      { 
        ?>
<b>[<?php echo $i; ?>]</b>
<?php
      } 
      
      if ( $i != $total_pages ) 
        ?>
  
<?php
    } 

    if ( $page != $total_pages )
    { 
      $nextpage = $page + 1; 

      ?>
 -  <a href="?op=search&page=<?php echo $total_pages; ?>&po=<?php echo $po; ?>&pt=<?php echo $pt; ?>&pp=<?php echo $pp; ?>&pb=<?php echo $pb; ?>&pl=<?php echo $pl; ?>&pp_min=<?php echo $pp_min; ?>&pp_max=<?php echo $pp_max; ?>">Próximo>></a>
<?php
    }

    ?>
</p>
</div>
<br />
<br />
<?php
  }
}
  else if ( $cgi->getValue ( "sp" ) == "y" )
 {
      // Start of Display Output
      require ( "includes/templates/layout_view_photos.php" );
      // End of Display output
}

  else
  {
    if ( !$cgi->getValue ( "op" ) == "SendInformationRequest" )
  {
    ?>
<br />
<br />
<h2 align="center"><?php echo FORM_TITLE; ?></h2>
<p align="center"><?php echo FORM_SEARCH_TEXT; ?></p>
<?php
     // Start of Search Box Output
    require ( "includes/templates/inc-searchbox.php" );
	 // End of Search Box Output
}
  }

?>
<br />
<p></p>

Dados Do Banco Com Php, Puxar Dados De Um Banco Via Php

29/07/2011, 15:18

Caros.

Tenho um banco onde estou puxando os dados, porém preciso que apereça outra informação de acordo com o que estiver no banco.
Ex: Quando estiver no banco propertyprice o que deverá ser mostrado é: Valor do Imóvel
Vai ficar assim:
propertyprice = Valor do Imóvel
propertytype = Tipo do Imóvel
propertylocation = Localização do Imóvel

Estes valores são fixos, porém não consigo uma forma de mostrar isso em uma combo ou em uma caixa de texto.


Muito obrigado.


Att.
Henrique Flausino

Erro Ao Tentar Enviar E-Mail Com Anexo

11/03/2011, 12:40

Olá pessoal.
Estou tendo problema com o script abaixo, não sei porque o servidor está me retornando o seguinte erro.

Warning: mail() [function.mail]: SAFE MODE Restriction in effect. The fifth parameter is disabled in SAFE MODE in /home/XXXXXXXX/public_html/Multi_Anexos/_inc/MultiAnexos.class.php on line 347

Index.php
<?php

require "_inc/MultiAnexos.class.php";

if( $_POST && MultiAnexos::is_mail($_POST['email']) ):

	// Instânciamos a classe, sem assunto
	$email = new MultiAnexos();
	$email->setMail('From', $_POST['email'], $_POST['nome']);
	$email->setMail('To', 'contato@mfdesign.com.br');
	$email->send();
	
endif;

?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>Multi-Anexos</title>
<link href="_css/typo.css" rel="stylesheet" type="text/css" />
<script type=text/javascript src="jquery.js"></SCRIPT>

</head>


<body>
<div id="div">


	<?php

	if( $_POST ):
		echo defined('SEND_RETURN') ?
		'<h2>'.SEND_RETURN.'</h2>' : '<h2>Informe seu nome e um email válido.</h2>' ;
	endif;


	// Exibindo as variáveis postadas após submeter o formulário
	#MultiAnexos::showPOST();

	// Exibindo um preview da mensagem html formatada
	#MultiAnexos::showHTML();

	?>


	<h1>Submetendo um formul&aacute;rio com m&uacute;ltiplos anexos</h1>	

	<p>Preencha o formulário abaixo para enviar sua mensagem.<br />É necessário preencher todos os campos.	</p>

	<form id="frm" action="<?=basename(__FILE__)?>" method="post" enctype="multipart/form-data">

	  <fieldset>
			<legend>
      <script language="JavaScript" type="text/javascript">

var currentcheckcontent,lastcheckcontent;
$(document).ready(function(){
    $("#addfileupload").click(function () {
        $("#fileuploads").append("<input type=\"file\" name=\"arquivo[]\" size=\"50\"><br />");
        return false;
    });
});


function getticketsuggestions() {
    currentcheckcontent = $("#message").val();
    if (currentcheckcontent!=lastcheckcontent && currentcheckcontent!="") {
        $.post("submitticket.php", { action: "getkbarticles", text: currentcheckcontent },
        function(data){
            if (data) {
                $("#searchresults").html(data);
                $("#searchresults").slideDown();
            }
        });
        lastcheckcontent = currentcheckcontent;
	}
    setTimeout('getticketsuggestions();', 3000);
}
getticketsuggestions();

      </script>
      Formulário de Contato</legend>
			<p>
		    <label for="nome">Nome:</label>
				<input id="nome" name="nome" />
			</p>
			<p>
				<label for="email">E-Mail:</label>
				<input id="email" name="email" />
			</p>
			<p>
				<label for="telefone">Telefone:</label>
				<input id="telefone" name="telefone" />
			</p>
			<p id=fileuploads>
				<label for="arquivo1">Anexo</label>
				<INPUT size=50 type=file name=arquivo[]>
		  </p><A id=addfileupload href="#"><IMG class=absmiddle border=0 alt="" src="add.gif"></A>
          <p></p>
		  <p>
	      <label for="mensagem">Mensagem:</label>
				<textarea id="mensagem" name="mensagem" cols="10" rows="10" class="text"></textarea>
			</p>
			<span>
				<input type="submit" value="ENVIAR" class="send" />
			</span>
		</fieldset>

	</form>


</div>
</body>
</html>
MultiAnexos.class.php
<?php

/**
 * Multi-Anexos | Multiple File Attachments 
 * Envio de e-mail com múltiplos arquivos anexados
 * 
 * @author Giovanni Ramos
 * @twitter @giovanni_ramos
 * @version 2.5
 * @since 2009-09-23 
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 *
**/


class MultiAnexos {

	public  static $head, $body;
	private $boundary = array();


	/**
	 * O objeto MultiAnexos ao ser instanciado, pode opcionalmente atribuir um assunto à mensagem
	 * 
	 * @access public
	 * @param string $subject Assunto da mensagem
	 * 
	 * */
	public function __construct($subject = null) {
		self::setHTML();
		self::setReturnPath();
		$this->subject = $subject;
		$this->boundary = '==Multipart_Boundary_'.md5(uniqid(time()));
	}


	/**
	 * Método para validar email
	 * 
	 * @access public
	 * @param string $mail E-mail a ser testado
	 * @return boolean Retorna true, se o e-mail for válido
	 *
	 * */
	public function is_mail($mail = null) {
		return (filter_var(trim($mail), FILTER_VALIDATE_EMAIL) ? true : false);
	}


	/**
	 * Método para atribuir um assunto à mensagem
	 * 
	 * @access public
	 * @param string $subject Assunto da mensagem
	 * @return void
	 *
	 * */
	public function setSubject($subject = null) {
		$this->subject = $subject;
	}


	/**
	 * Método para recuperar o assunto da mensagem
	 * 
	 * @access private
	 * @return string Retorna o assunto da mensagem. Se nenhum for definido, retorna o Subject: "Sem assunto"
	 *
	 * */
	private function getSubject() {
		return (!is_null($this->subject)) ? $this->subject : "Sem assunto";
	}


	/**
	 * Método para incorporar um e-mail à mensagem
	 * 
	 * @access public
	 * @param string $type Tipo pré-definido de e-mail: From, To, Cc, Bcc ou Reply-To
	 * @param string $email Endereço de e-mail
	 * @param string $name Um nome ou apelido para o e-mail (opcional)
	 * @return array Retorna o email
	 *
	 * */
    public function setMail($type, $mail = null, $name = null) {
		if(isset($mail) && self::is_mail($mail)):
    		$type = strtolower($type);
    		$type = str_replace('-', null, $type);
    		$type = str_replace('_', null, $type);

			if(isset($type) && ereg('^[[:lower:]]*$', $type)):
		        if(!is_array($this->$type))
		            $this->$type = array();
		        array_push($this->$type, array($mail, $name));
		        return $this->$type;
 			endif;
     	endif;
    }


	/**
	 * Método para retornar a lista de e-mails atribuída à mensagem
	 * 
	 * @access public
	 * @param string $type Tipo de e-mail: From, To, Cc, Bcc ou Reply-To
	 * @return string Retorna a lista de acordo com o tipo
	 *
	 * */
	 public function getMail($type) {
		if(isset($type)):
			if(!$this->$type) return false;
			if(!is_array($list)) $list = array(); 

			foreach($this->$type as $k => $v)
				if(is_array($v))
					$list[] = (is_null($v[1])) ? $v[0] : $v[1].' <'.$v[0].'>';
			return implode(', ', $list);
		endif;
	}


	/**
	 * Método para incorporar um e-mail de retorno em caso de falha no envio da mensagem
	 * IMPORTANTE: Informar um Return-Path, evita bloqueios anti-spam de servidores como Gmail ou Hotmail
	 * 
	 * @access public
	 * @param string $setReturnPath Por padrão um e-mail de retorno será atribuído a mensagem
	 * @return void
	 *
	 * */
	public function setReturnPath($setReturnPath = true) {
		$this->setReturnPath = $setReturnPath;
	}


 	/**
	 * Método para recuperar o e-mail de retorno da mensagem
	 * 
	 * @access private
	 * @return string Retorna o e-mail de retorno
	 *
	 * */
	private function getReturnPath() {
		return (!is_bool($this->setReturnPath)) ? $this->setReturnPath : ( (bool)$this->setReturnPath ? $this->from[0][1] : null );
	}


 	/**
	 * Método para capturar variáveis enviadas via post, pelo formulário 
	 * 
	 * @access private
	 * @return string Retorna a lista de variáveis
	 *
	 * */
	public function getPOST() { 
		$list = null;
		foreach($_POST as $k => $v)
			$list.= '<b>'.ucfirst($k).':</b> '.$v.'<br />';
		return $list;
	}


 	/**
	 * Método para exibir as variáveis submetidas pelo formulário
	 * 
	 * @access static
	 * @return string void
	 *
	 * */
	static function showPOST() {
		if($_POST)
			echo '<pre>',htmlspecialchars(print_r($_POST, true)),'</pre>';
	}


 	/**
	 * Método para formatar o conteúdo da mensagem
	 * 
	 * @access public
	 * @return string void
	 *
	 * */
	public function setHTML($body = null) {
		self::$body = (!is_null($body)) ? $body :
		'<!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="pt-BR" lang="pt-BR">
			<head>
			<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
			<style>
			body 		{background:#FFFFFF;}
			a, a:link 	{color:#5b6105; text-decoration:none;}
			table 		{margin:0; padding:0; border:1px solid #8F8E96; width:500px;}
			table tr 	{background:#F6F6F6; }
			table td 	{color:#000000; font: normal 11px arial, helvetica, sans-serif; border:dashed 1px #DDD; padding:30px;}
			</style>
			</head>
			<body>
			<br />
			<table border="0" cellspacing="10" cellpadding="0">
			<tr>
				<td>
				'.self::getPOST().'
				</td>
			</tr>
			</table>
			<br />
			</body>
			</html>
		';
	}


 	/**
	 * Método para limpar os espaços tabulados na mensagem 
	 * 
	 * @access public
	 * @return string void
	 *
	 * */
	public function getHTML() {
		return str_replace("\t",null,self::$body);
	}


 	/**
	 * Método para exibir a mensagem enviada no corpo do e-mail
	 * 
	 * @access static
	 * @return string void
	 *
	 * */
	static function showHTML() {
		if($_POST)
			echo self::$body;
	}


 	/**
	 * Método para preparar o cabeçalho da mensagem
	 * 
	 * @access public
	 * @return string void
	 *
	 * */
	public function setHeader($multipart = false) {
		self::$head 
		= ('MIME-Version: 1.0'.PHP_EOL)
		. ('From: '.self::getMail("from").PHP_EOL)
		. ('X-Mailer: MultiAnexos v.2.0 PHP/'.phpversion().' '.PHP_EOL)
		. ((!empty($this->to[0][0])) ? 'To: '.self::getMail("to").PHP_EOL : NULL)
		. ((!empty($this->replyto[0][0])) ? 'Reply-To: '.self::getMail("replyto").PHP_EOL : NULL)
		. ((!empty($this->cc[0][0])) ? 'Cc: '.self::getMail("cc").PHP_EOL : NULL)
		. ((!empty($this->bcc[0][0])) ? 'Bcc: '.self::getMail("bcc").PHP_EOL : NULL)
		. ('Content-type: '.(($multipart) ? 'multipart/mixed; boundary="'.$this->boundary.'"'.PHP_EOL:'text/html; charset="ISO-8859-1"').PHP_EOL);
	}


 	/**
	 * Método para recuperar o cabeçalho da mensagem
	 * 
	 * @access public
	 * @return string Retorna o HEADER da mensagem
	 *
	 * */
	public function getHeader() {
		return self::$head;
	}


 	/**
	 * Método para submeter a mensagem
	 * 
	 * @access public
	 * @return boolean Retorna o status do envio
	 *
	 * */
	public function send() {

		// Verifico se o formulário submetido, possui algum arquivo anexo
		$file = (isset($_FILES['arquivo']) && in_array('0',$_FILES['arquivo']['error'])) ? $_FILES['arquivo'] : FALSE;

		$subj = self::getSubject();

		$body = self::getHTML();

		self::setHeader((bool) $file);
		$head = self::getHeader();

		// Executo a condição seguinte, se identificar um ou mais anexos junto a mensagem
		if($file){

			// Removendo da matriz os anexos falsos
			for ($x=0; $x<count($_FILES['arquivo']['name']); $x++):
				if($file['error'][$x] <> UPLOAD_ERR_OK){
					unset($file['name'][$x]);
					unset($file['size'][$x]);
					unset($file['type'][$x]);
					unset($file['tmp_name'][$x]);
					unset($file['error'][$x]);
				}else{
					$attach[] = array(
						$file['name'][$x], 
						$file['size'][$x], 
						$file['type'][$x], 
						$file['tmp_name'][$x]
					);
				}
			endfor;


			$html = stripslashes($body);

			// Criando os cabeçalhos MIME utilizados para separar as partes da mensagem 
			$body = '--'.$this->boundary.PHP_EOL;
			$body.= 'Content-Type: text/html; charset="ISO-8859-1"'.PHP_EOL;
			$body.= 'Content-Transfer-Encoding: 8bit'.PHP_EOL.PHP_EOL;
			$body.= $html.PHP_EOL;
			$body.= '--'.$this->boundary.PHP_EOL;

			for ($i=0; $i<sizeof($attach); $i++):
				if(is_uploaded_file($attach[$i][3])) {
					$Name = $attach[$i][0];
					$Size = $attach[$i][1];
					$Type = $attach[$i][2];
					$Temp = $attach[$i][3];

					if((strlen($Name)>1) && ($Size>0)) {
						$fopen = fopen($Temp,"rb");
						$fread = fread($fopen, filesize($Temp));
						$cript = base64_encode($fread);
						$close = fclose($fopen);
						$chunk = chunk_split($cript);
	
						$body.= 'Content-Disposition: attachment; filename="'.$Name.'"'.PHP_EOL;
						$body.= 'Content-Type: '.$Type.'; name="'.$Name.'"'.PHP_EOL;
						$body.= 'Content-Transfer-Encoding: base64'.PHP_EOL.PHP_EOL;
						$body.= $chunk.PHP_EOL;
						$body.= '--'.$this->boundary;
						$body.= (sizeof($attach) == $i+1) ? '--'.PHP_EOL.PHP_EOL : PHP_EOL;
					}
				}
			endfor;

		}

		// Enviando a mensagem e definindo uma mensagem de status do envio em SEND_RETURN
		$status = mail(null, $subj, $body, $head, ((bool) $this->setReturnPath ? '-f'.self::getReturnPath() : null)) ? true : false;

		$status_message = ($status) ?
		'<span class="mail_ok">Sua mensagem foi enviada com sucesso.</span>' : 
		'<span class="mail_no">Sua mensagem n&atilde;o p&ocirc;de ser enviada.</span><br /><br />Por favor tente novamente mais tarde.' ;

		define('SEND_RETURN', $status_message);
		
		return $status;
	}

}


?>

Alguém pode me ajudar?


Atenciosamente.
Henrique Flausino

Problema solucionado.
Para quem precisar estou colocando o código na integra para Down, pois tive de procurar muito para achar ele.
O melhor é que tem um sistema muito legal de add novos campos de anexos.
Já testei e está funcionando 100%.


Download: http://www.fileserve.com/file/EuGGXzs


Att.
Henrique Flausino

IPB Skin By Virteq