4
I’m trying to create a real estate company On-Line, I have already built the structure, but I have no idea how to register the States, Cities and Neighborhoods of the same using a Combobox.
For those who can give an analysis I leave the address http://www.buziosnegocios.com.br/ to see that Combobox is working, because I registered directly in the BD the data of a test property in the state of Rio de Janeiro.
If friends can give me an idea of how to register real estate ads with Combobox, or otherwise I would be very grateful.
Below I relate the code I created and only managed to register the state code, state name and state acronym.
First Stage: Selecting the State.
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<?php
if(isset($_POST['enter'])){
$dp = $_POST['cod_estado'];
echo "<script language='javascript'>window.location='cadastrar_anuncio_2.php?cod_estado=$dp'</script>";
}
?>
<form name="enter" method="post" action="" enctype="multipart/form-data">
<label>Selecione o estado de origem do Imóvel</label><br /><br />
<select name="cod_estado">
<?php
include 'conexao.php';
$select = mysql_query("SELECT * FROM estados ORDER BY nome_estado ASC");
while($res = mysql_fetch_array($select)){
?>
<option value="<?php echo $estados = $res['cod_estado'];?>"><?php echo $estados = $res['nome_estado'];?></option>
<?php } ?>
</select><br /><br />
<input class="input" type="submit" name="enter" value="Avançar"/>
</form>
Phase Two: Recording Status Data.
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<?php
if(isset($_POST['cadastrar'])){
$dp = $_POST['cod_estado'];
echo "<script language='javascript'>window.location='cadastrar_anuncio_3.php?cod_estado=$dp'</script>";
}
?>
<form name="cadastrar" action="" method="post" enctype="multipart/form-data" >
<?php
$dp = $_POST['cod_estado'];
include "conexao.php";
$cod_estado = $_GET['cod_estado'];
$query = mysql_query("SELECT * FROM estados WHERE cod_estado = '$cod_estado'");
$res = mysql_fetch_array($query);
if(isset($_POST['cadastrar'])){
$nome_estado = $_POST['nome_estado'];
$uf = $_POST['uf'];
$cod_estado = $_GET['cod_estado'];
$insert = mysql_query("INSERT INTO anuncio VALUES ('NULL', '$cod_estado', '$nome_estado', '$uf', '$cod_cidade', '$nome_cidade', '$cod_bairro', '$nome_bairro', '$foto01')")or die(mysql_error());
if($insert == ''){
echo "<script language='javascript'>
window.alert('Erro ao cadastrar Anuncio!!!');
</script>";
}else{
echo "<meta http-equiv='refresh' content='0; URL= cadastrar_anuncio_3.php?cod_estado=".$cod_estado."'>
<script language='javascript'>
window.alert('Cidade cadastrada com sucesso!!!');
</script>";
}}
$dp = $_POST['cod_estado'];
include 'conexao.php';
$uf = $_GET['uf'];
$nome_estado = $_GET['nome_estado'];
$cod_estado = $_GET['cod_estado'];
$query = mysql_query("SELECT * FROM estados WHERE cod_estado = '$cod_estado'");
$res = mysql_fetch_array($query);
?>
<input size="1" type="text" name="cod_estado" value="<?php echo $res['cod_estado']; ?>" readonly="readonly"/>
<input size="20" type="text" name="nome_estado" value="<?php echo $res['nome_estado']; ?>" readonly="readonly"/>
<input size="1" type="text" name="uf" value="<?php echo $res['uf']; ?>" readonly="readonly"/>
<input type="submit" name="cadastrar" value="Cadastrar" />
</form>
From now on, I don’t know how to proceed. If friends can give me a light, I’d be grateful.
Hugs to all.
Sergio, I’m not sure I understand your question, what exactly do you need? A better way to search the properties? What exactly is your problem with the property code structure? I always made this type of registration in the database as follows, a state table and other municipalities, there in each ad would have the register of the neighborhood, to make the search. Example of the structure here, but without the country: http://samus.com.br/web/artigo-todas_cities_do_brasil_updated_e_com_accents
– Ruggi
Hello Ruggi, is the following, I’m trying to make a website for a friend who is a realtor, he would like to register the properties on own site. But I’m not getting to register real estate according to states, cities and neighborhoods. Example: A house in São Paulo, in the city of Araraquara and in the Centro neighborhood, I would have to register them with the codes of each respective state, city and neighborhood, this is what I’m not able to pull the combobox, since in it I have all the codes of states, cities and neighborhoods. Did I manage to make myself understood......
– Sergio Murilo Cabral
Continuing... I came to register the state code, the name of the state and the acronym of the state, but I stopped, I do not know how to continue the registration of the City and Neighborhood, pulling from Combobox. I published the code used to register the status so that the search for the property can be done.... It seems that I’ve stalled even more... Well that’s what I hope you’ve managed to make me understand.
– Sergio Murilo Cabral