Jump to content


Photo

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


  • Faça o login para participar
5 replies to this topic

#1 Henrique Flausino

Henrique Flausino

    Turista

  • Usuários
  • 41 posts
  • Sexo:Masculino
  • Localidade:São Paulo

Posted 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

#2 Diego Bezerra

Diego Bezerra

    Diego Bezerra

  • Moderadores
  • 938 posts
  • Sexo:Masculino
  • Localidade:Amazonas
  • Interesses:Iniciando no C# com MSSQL.

Posted 29/07/2011, 16:18

coloque o codigo de como vc ta fazendo
Att.
Diego Bezerra
Agência Kernel - em Breve
Email/msn: diegobezerra@outlook.com
Facebook

#3 Henrique Flausino

Henrique Flausino

    Turista

  • Usuários
  • 41 posts
  • Sexo:Masculino
  • Localidade:São Paulo

Posted 29/07/2011, 17:48

coloque o codigo de como vc ta fazendo

<?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/Auth.php" );
$auth = new Auth ( $cgi, $sql, $admin_table );
$auth->checkAuth ( "index.php" );

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<title>Administração Geral de Imóveis</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="style.css" rel="stylesheet" type="text/css" /> 
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head> 
<body> 
<table border="0" cellpadding="1" cellspacing="0" width="100%"> 
<tbody> 
<tr> 
<td bgcolor="#333333"> <?PHP include "header.php"; ?>
<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="100%"> 
<tbody> 
<tr> 
<td colspan="4"> 
<table width="100%" cellpadding="0" cellspacing="0"> 
<tr> 
<td align="left" valign="top" class="leftbg"> <?PHP include "leftmenu.php"; ?></td> 
<td valign="top"> 
<h2 align="left"><img src="images/spacer.gif" height="10" width="15" />Configura&ccedil;&otilde;es</h2> 

<table width="95%" align="center" cellpadding="0" cellspacing="1">
<tr>
<td> As defini&ccedil;&otilde;es nesta p&aacute;gina precisa ser configurada corretamente para permitir o bom funcionamento de suas propriedades em seu site. Certifique-se de que todas as informa&ccedil;&otilde;es inseridas est&atilde;o corretas.</td>
</tr>
</table><br />

<?php

  if ( $cgi->getValue ( "op" ) == "UpdateConfigure" )
  {
    $sql->execute ( "UPDATE " . $configure_table . " SET  
      websiteurl=" . $sql->quote ( $cgi->getValue ( "websiteurl" ) ) . ", 
      imagepath=" . $sql->quote ( $cgi->getValue ( "imagepath" ) ) . ", 
      imageurl=" . $sql->quote ( $cgi->getValue ( "imageurl" ) ) . ", 
      language_pack=" . $sql->quote ( $cgi->getValue ( "language_pack" ) ) . ", 
      display_rental=" . $sql->quote ( $cgi->getValue ( "display_rental" ) ) . ", 
      display_sale=" . $sql->quote ( $cgi->getValue ( "display_sale" ) ) . ", 
      display_search_types=" . $sql->quote ( $cgi->getValue ( "display_search_types" ) ) . ", 
      display_search_locations=" . $sql->quote ( $cgi->getValue ( "display_search_locations" ) ) . ", 
      display_search_bedrooms=" . $sql->quote ( $cgi->getValue ( "display_search_bedrooms" ) ) . ",
      display_search_max_price=" . $sql->quote ( $cgi->getValue ( "display_search_max_price" ) ) . ",
      property_search_order=" . $sql->quote ( $cgi->getValue ( "property_search_order" ) ) . ", 
      property_search_ordering=" . $sql->quote ( $cgi->getValue ( "property_search_ordering" ) ) . ", 
      property_search_limit=" . $sql->quote ( $cgi->getValue ( "property_search_limit" ) ) . ", 
      property_map_url=" . $sql->quote ( $cgi->getValue ( "property_map_url" ) ) . ", 
      max_image_resize_width=" . $sql->quote ( $cgi->getValue ( "max_image_resize_width" ) ) . ", 
      max_thumb_image_height=" . $sql->quote ( $cgi->getValue ( "max_thumb_image_height" ) ) . ", 
      max_thumb_image_width=" . $sql->quote ( $cgi->getValue ( "max_thumb_image_width" ) ) . ",
	  template_page_name=" . $sql->quote ( $cgi->getValue ( "template_page_name" ) ) . "
  " );

    ?>
<br />
<p align="center"><font color="red">As configura&ccedil;&otilde;es foram atualizadas com sucesso! </font></p>
<?php
  }

  $rows = $sql->execute ( "SELECT * FROM " . $configure_table . " LIMIT 1",
    SQL_RETURN_ASSOC );
  $row = $rows [ 0 ];

?>
<form method="post">
<input name="op" type="hidden" value="UpdateConfigure" />
<p align="center"></p>
<table width="85%" align="center" cellpadding="2" cellspacing="1">
<tr>
  <td height="32" colspan="2" align="left" valign="middle" background="images/top-menubg.gif" class="leftbg"> <b>Configura&ccedil;&otilde;es e Logotipo</b></td>  
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3">Website URL:</td>
<td><input type="text" name="websiteurl" size="45" maxlength="125" value="<?php echo $cgi->htmlEncode ( $row [ "websiteurl" ] ); ?>" /></td>
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3">  Path. Local da pasta das Imagens:</td>
<td><input type="text" name="imagepath" size="45" maxlength="125" value="<?php echo $cgi->htmlEncode ( $row [ "imagepath" ] ); ?>" /> 
  <span class="style1">n&atilde;o mexer sem conhecimento</span> </td>
</tr>
<tr>
<td align="right" valign="top" bgcolor="#F3F3F3">URL da pasta das Imagens:</td>
<td valign="top"><input type="text" name="imageurl" size="45" maxlength="125" value="<?php echo $cgi->htmlEncode ( $row [ "imageurl" ] ); ?>" />
  <span class="style1">n&atilde;o mexer sem conhecimento</span> <br />
  <br /></td>
</tr>
<tr>
  <td height="32" colspan="2" align="left" valign="middle" background="images/top-menubg.gif" class="leftbg"> <b>Nome do arquivo principal</b></td>  
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3">Nome do arquivo:</td>
<td><input type="text" name="template_page_name" size="45" maxlength="125" value="<?php echo $cgi->htmlEncode ( $row [ "template_page_name" ] ); ?>" /> <span class="style1">n&atilde;o mexer sem conhecimento</span>  </td>
</tr>
<tr>
  <td height="32" colspan="2" align="left" valign="middle" background="images/top-menubg.gif" class="leftbg"> <b>Defini&ccedil;&atilde;o de Idiomas </b></td>  
</tr><tr>
<td align="right" valign="top" bgcolor="#F3F3F3">Idioma:</td>
<td valign="top">
<select name="language_pack"><?php 
$dirname = "../$LanguageFolder";
$dh = opendir( $dirname ) or die("Could not find Language Director");
while ( ! ( ( $langpack = readdir( $dh ) ) === false ) ) {
       if ($langpack != "." && $langpack != "..") {
echo "<option value=\"$langpack\"";  
if ( $row [ "language_pack" ] == "$langpack" ) { echo " selected"; }
echo ">$langpack</option>";
       } }
closedir( $dh );


?>
</select>
<br />
<br /></td>
</tr>
<tr>
  <td height="32" colspan="2" align="left" valign="middle" background="images/top-menubg.gif" class="leftbg"> <b>Op&ccedil;&otilde;es de Pesquisa/Busca</b></td>  
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3"> Mostrar Aluguel:</td>
<td><input name="display_rental" type="radio" value="Y"<?php if ( $row [ "display_rental" ] == "Y" ) { echo " checked"; } ?> /> 
Sim &nbsp;
  <input name="display_rental" type="radio" value="N"<?php if ( $row [ "display_rental" ] == "N" ) { echo " checked"; } ?> /> 
  N&atilde;o</td>
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3">Mostrar Vendas:</td>
<td><input name="display_sale" type="radio" value="Y"<?php if ( $row [ "display_sale" ] == "Y" ) { echo " checked"; } ?> />   Sim&nbsp;&nbsp;
  <input name="display_sale" type="radio" value="N"<?php if ( $row [ "display_sale" ] == "N" ) { echo " checked"; } ?> />   N&atilde;o</td>
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3">Mostrar Busca por Im&oacute;veis:</td>
<td><input name="display_search_types" type="radio" value="Y"<?php if ( $row [ "display_search_types" ] == "Y" ) { echo " checked"; } ?> />   Sim&nbsp;&nbsp;
  <input name="display_search_types" type="radio" value="N"<?php if ( $row [ "display_search_types" ] == "N" ) { echo " checked"; } ?> />   N&atilde;o</td>
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3">Mostrar Busca por Localiza&ccedil;&atilde;o:</td>
<td><input name="display_search_locations" type="radio" value="Y"<?php if ( $row [ "display_search_locations" ] == "Y" ) { echo " checked"; } ?> />   Sim&nbsp;&nbsp;
  <input name="display_search_locations" type="radio" value="N"<?php if ( $row [ "display_search_locations" ] == "N" ) { echo " checked"; } ?> />   N&atilde;o</td>
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3">Mostrar Busca por Quartos:</td>
<td><input name="display_search_bedrooms" type="radio" value="Y"<?php if ( $row [ "display_search_bedrooms" ] == "Y" ) { echo " checked"; } ?> />   Sim&nbsp;&nbsp;
  <input name="display_search_bedrooms" type="radio" value="N"<?php if ( $row [ "display_search_bedrooms" ] == "N" ) { echo " checked"; } ?> />   N&atilde;o</td>
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3">Mostrar Busca por Pre&ccedil;o:</td>
<td><input name="display_search_max_price" type="radio" value="Y"<?php if ( $row [ "display_search_max_price" ] == "Y" ) { echo " checked"; } ?> />   Sim&nbsp;&nbsp;
  <input name="display_search_max_price" type="radio" value="N"<?php if ( $row [ "display_search_max_price" ] == "N" ) { echo " checked"; } ?> /> 
N&atilde;o</td>
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3"> Resultados por ordem da pesquisa:</td>
<td><select name="property_search_order">
  <option value="propertyprice">Valor do Im&oacute;vel</option>
  <option value="propertytype">Tipo do Im&oacute;vel</option>
  <option value="propertylocation">Localiza&ccedil;&atilde;o do Im&oacute;vel</option> 
</select> 
Atual: 
<input name="Atual2" type="text" disabled="disabled" value="<?php echo $cgi->htmlEncode ( $row [ "property_search_order" ] ); ?>" size="15" maxlength="4" readonly="readonly" /></td>
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3">Mostrar Resultados da busca por:</td>
<td><select name="property_search_ordering">
    <option value="Ascendente">Ascendente</option>
    <option value="Descendente">Descendente</option>
</select> 
  Atual: 
  <input name="Atual" type="text" disabled="disabled" value="<?php echo $cgi->htmlEncode ( $row [ "property_search_ordering" ] ); ?>" size="15" maxlength="4" readonly="readonly" /></td>
</tr>
<tr>
<td align="right" valign="top" bgcolor="#F3F3F3">M&aacute;x. de Resultados por P&aacute;gina:</td>
<td valign="top"><input type="text" name="property_search_limit" size="10" maxlength="4" value="<?php echo $cgi->htmlEncode ( $row [ "property_search_limit" ] ); ?>" />
  <br />
  <br /></td>
</tr>
<tr>
  <td height="32" colspan="2" align="left" valign="middle" background="images/top-menubg.gif" class="leftbg"> <b>Localiza&ccedil;&atilde;o de Im&oacute;veis por Cep e Mapa</b></td>  
</tr>
<tr>
<td align="right" valign="top" bgcolor="#F3F3F3"> Pesquisar por Cep ou Mapa - URL:</td>
<td><input type="text" name="property_map_url" size="55" maxlength="200"
value="<?php echo $cgi->htmlEncode ( $row [ "property_map_url" ] ); ?>" />
<br />
(Isso permitir&aacute; que voc&ecirc; exiba um mapa para procurar um imovel pelo cep autamaticamente.<br />
Deixamos como padr&atilde;o o Google, mas pode ser alterado caso tenha conhecimento e outra URL confi&aacute;vel. Temos <strong>3</strong> op&ccedil;&otilde;es abaixo.)<br />
<b>Google Maps:</b> http://local.google.com/local?f=q&amp;hl=en&amp;q=XXXXXX<br />
<b>Street Map:</b>
http://www.streetmap.co.uk/streetmap.dll?postcode2map?XXXXXX<br />
<b>Multimap:</b>
http://www.multimap.com/map/browse.cgi?local=h&amp;scale=10000&amp;pc=XXXXXX<br />
<br /></td>
</tr>
<tr>
  <td height="32" colspan="2" align="left" valign="middle" background="images/top-menubg.gif" class="leftbg"> <b>Configura&ccedil;&atilde;o do Tamanho da Imagem de Exibi&ccedil;&atilde;o </b></td>  
</tr>
<tr>
  <td colspan="2" bgcolor="#F3F3F3"> Isso se aplica aos retratos e paisagens das fotografias. Largura e Altura das imagens exibidas no site <br />
<br /></td>
  </tr>
<tr>
<td align="right" bgcolor="#F3F3F3">Tamanho da Imagem:</td>
<td><input type="text" name="max_image_resize_width" size="5" maxlength="4" value="<?php echo $cgi->htmlEncode ( $row [ "max_image_resize_width" ] ); ?>" />
px </td>
</tr>
<tr>
  <td align="right" bgcolor="#F3F3F3">&nbsp;</td>
  <td>&nbsp;</td>
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3">Altura da Imagem:</td>
<td><input type="text" name="max_thumb_image_height" size="5" maxlength="4" value="<?php echo $cgi->htmlEncode ( $row [ "max_thumb_image_height" ] ); ?>" />
px - 


 Esta &eacute; para a p&aacute;gina de resultados da pesquisa</td>
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3">Largura da Imagem:</td>
<td><input type="text" name="max_thumb_image_width" size="5" maxlength="4" value="<?php echo $cgi->htmlEncode ( $row [ "max_thumb_image_width" ] ); ?>" />
px - Esta &eacute; para a p&aacute;gina de resultados da pesquisa</td>
</tr>
<tr><td height="20" align="left" valign="middle" class="leftbg" colspan="2">&nbsp; </td>  
</tr>
</table>
<p align="center">
<input type="submit" class="submit" value="Atualizar" onclick="return confirm('Tem certeza de que deseja atualizar?');" />
</p>
</form>
<br /></td>
</tr> 
</table> </td> 
</tr> 
</tbody> 
</table> </td> 
</tr> 
</tbody> 
</table> <?PHP include "footer.php"; ?>
</body>
</html>


Pessoal, vou ser mais claro.
Já consegui puxar os dados do banco, mas preciso que o resultados seja mostrado assim:
Quando o resultado for "propertyprice" deverá ser mostrado "Valor do Imóvel" e assim por diante, para mais 2 outros resoltados.


Att.
Henrique Flausino

#4 André Manoel

André Manoel

    Doutor

  • Usuários
  • 996 posts
  • Sexo:Masculino
  • Localidade:Brasilia

Posted 31/07/2011, 00:45

Vc pode usar o IF...

Quando vc for mostrar os registros vc compara qual campo foi retornado e exibe o que quer...
Iniciando na Ajuda On line...

Posted Image Meu post lhe ajudou? Reputar/votar é uma das formas de agradecer.

#5 Henrique Flausino

Henrique Flausino

    Turista

  • Usuários
  • 41 posts
  • Sexo:Masculino
  • Localidade:São Paulo

Posted 02/08/2011, 20:11

Vc pode usar o IF...

Quando vc for mostrar os registros vc compara qual campo foi retornado e exibe o que quer...

Só tem um problema... não sei como fazer isso.
Este código fiz olhando diversos outros.. mas não sei contar esta lógica que vc me passou.
Poderia me mostrar como fazer?

#6 Henrique Flausino

Henrique Flausino

    Turista

  • Usuários
  • 41 posts
  • Sexo:Masculino
  • Localidade:São Paulo

Posted 05/08/2011, 14:56

Pessoal, resolvi o problema com a ajuda do André Manoel.
Foi simples, bastou fazer uma comparação com IF.
Abaixo código caso alguém tenha uma duvida parecida, já tem uma solução.
<input name="bar" type="text" disabled="disabled" id="bar" value="<?php  $bar = $cgi->htmlEncode ( $row [ "property_search_order" ] );
if($bar === "propertyprice")
echo "Valor do Im&oacute;vel";
if($bar === "propertytype")
echo "Tipo do Im&oacute;vel";
if($bar === "propertylocation")
echo "Localiza&ccedil;&atilde;o do Im&oacute;vel"; ?>" size="20" maxlength="4" readonly="readonly" />

Att.
Henrique Flausino




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq