18 Out 2013 20:30
<html>
<body>
<form action="filtrar.php" method="post">
<label>Escolha a base:</label>
<input type="text" name="filtro2" id="filtro2" value="Digite aqui o nome da base a ser pesquisada" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Digite aqui o nome da base a ser pesquisada';}">
<input type="submit" id="Pesquisar" value="Pesquisar">
</form>
</body>
</html>
18 Out 2013 21:40
<html>
<body>
<form action="filtrar.php" method="post">
<label>Escolha a base:</label>
<select name="filtro2">
<?php
foreach (glob("*.dbf") as $arquivo) {
$arq_ = str_replace(".DBF","",strtoupper($arquivo));
?>
<option value="<?php echo $arq_; ?>"><?php echo $arq_; ?></option>
<?php
}
?>
</select>
<input type="submit" id="Pesquisar" value="Pesquisar">
</form>
</body>
</html>
18 Out 2013 22:11
<html>
<body>
<form action="filtrar.php" method="post">
<label>Pesquisar por:</label>
<input type="text" name="filtro" id="filtro" value="Digite aqui parte do texto procurado" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Digite aqui parte do texto procurado';}">
<label>Escolha a base:</label>
<select name="filtro2">
<?php
foreach (glob("*.dbf") as $arquivo) {
$arq_ = str_replace(".DBF","",strtoupper($arquivo));
?>
<option value="<?php echo $arq_; ?>"><?php echo $arq_; ?></option>
<?php
}
?>
<label>No campo:</label>
<input type="text" name="filtro3" id="filtro3" value="Digite aqui o nome do campo a ser pesquisado" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Digite aqui o nome do campo a ser procurado';}">
</select>
<input type="submit" id="Pesquisar" value="Pesquisar">
</form>
</body>
</html>
18 Out 2013 23:40
foreach (glob("/pasta/*.dbf") as $arquivo) {
19 Out 2013 00:49
PHP Warning: odbc_exec() [<a href='function.odbc-exec'>function.odbc-exec</a>]: SQL error: [Microsoft][ODBC dBase Driver] Syntax error in FROM clause., SQL state 37000 in SQLExecDirect in C:\Inetpub\Wwwroot\inaciobr\filtrar.php on line 13
<html>
<body>
<label>Escolha a base:</label>
<select name="filtro">
<?php
foreach (glob("meusarq/agenda/*.dbf") as $arquivo) {
$arq_ = str_replace(".DBF","",strtoupper($arquivo));
?>
<option value="<?php echo $arq_; ?>"><?php echo $arq_; ?></option>
<?php
}
?>
<label>No campo:</label>
<input type="text" name="filtro2" id="filtro2" value="Digite aqui o nome do campo a ser pesquisado" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Digite aqui o nome do campo a ser procurado';}">
<form action="filtrar.php" method="post">
<label>Pesquisar por:</label>
<input type="text" name="filtro3" id="filtro3" value="Digite aqui parte do texto procurado" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Digite aqui parte do texto procurado';}">
</select>
<input type="submit" id="Pesquisar" value="Pesquisar">
</form>
</body>
</html>
<?
$txtBase = $_POST["filtro"];
$txtCampo = $_POST["filtro2"];
$txtFiltro = $_POST["filtro3"];
$dsn = "DRIVER={Microsoft dBase Driver (*.dbf)};DBQ=".dirname($_SERVER['SCRIPT_FILENAME']).";";
$conn= odbc_connect($dsn,"","");
if(!$conn)
{ exit("conexao falhou: ".odbc_errormsg()); }
$sql="SELECT * FROM ".$txtBase." WHERE ".$txtCampo." LIKE '%".$txtFiltro."%'";
echo $sql;
echo $dns;
$rs=odbc_exec($conn,$sql);
if (!$rs)
{exit("Error in SQL");}
echo "<table BORDER=1><tr>";
echo "<th>data</th>";
echo "<th>".txtCampo."</th></tr>";
while (odbc_fetch_row($rs))
{
$compname=odbc_result($rs,"data");
$conname=odbc_result($rs,$txtCampo);
echo "<tr><td>$compname</td>";
echo "<td>$conname</td></tr>";
}
odbc_close($conn);
echo "</tr></table>";
?>
19 Out 2013 09:55
<form action="filtrar.php" method="post">
</select>
cjp escreveu:Mas eu pensei que daria pra fazer em PHPs separados. No primeiro, o usuário escolhe o arquivo. Daí outro PHP seria chamado para o usuário escolher o campo da base.
cjp escreveu:De qualquer forma, para isso eu ainda precisaria de alguma função que retornasse a estrutura do arquivo, né?
19 Out 2013 10:59
PHP Warning: odbc_exec() [<a href='function.odbc-exec'>function.odbc-exec</a>]: SQL error: [Microsoft][ODBC dBase Driver] Syntax error in FROM clause., SQL state 37000 in SQLExecDirect in C:\Inetpub\Wwwroot\inaciobr\filtrar.php on line 13
<html>
<body>
<form action="filtrar.php" method="post">
<label>Escolha a base:</label>
<select name="filtro">
<?php
foreach (glob("meusarq/agenda/*.dbf") as $arquivo) {
$arq_ = str_replace(".DBF","",strtoupper($arquivo));
?>
<option value="<?php echo $arq_; ?>"><?php echo $arq_; ?></option>
<?php
}
?>
</select>
<label>No campo:</label>
<input type="text" name="filtro2" id="filtro2" value="Digite aqui o nome do campo a ser pesquisado" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Digite aqui o nome do campo a ser procurado';}">
<label>Pesquisar por:</label>
<input type="text" name="filtro3" id="filtro3" value="Digite aqui parte do texto procurado" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Digite aqui parte do texto procurado';}">
<input type="submit" id="Pesquisar" value="Pesquisar">
</form>
</body>
</html>
19 Out 2013 11:24
$arq_ = str_replace(".DBF","",strtoupper($arquivo));
$arq_ = str_replace("MEUSARQ/AGENDA/","",$arq_);
cjp escreveu:... se isso dispensar o uso de Jquery e outras coisas que não conheço. O único problema é como saber a estrutura do arquivo...
19 Out 2013 11:37
26 Out 2013 17:42
<?
$dsn = "DRIVER={Microsoft dBase Driver (*.dbf)};DBQ=".dirname($_SERVER['SCRIPT_FILENAME']).";";
$conn= odbc_connect($dsn,"","");
if(!$conn)
{ exit("conexao falhou: ".odbc_errormsg()); }
$sql="SELECT * FROM agcom WHERE compr LIKE '%".$txtFiltro."%'";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{exit("Error in SQL");}
$i = 0;
$fieldCount = odbc_num_fields($rs);
echo " <table$css_table>\n";
echo " <tr$css_tr>\n";
while ($i < $fieldCount)
{
$i++;
$fieldName = odbc_field_name($rs, $i);
echo " <th$css_th>$fieldName</th>\n";
}
echo " </tr>\n";
odbc_close($conn);
?>
27 Out 2013 00:45
27 Out 2013 23:48
28 Out 2013 09:39
DBQ=".dirname($_SERVER['SCRIPT_FILENAME'])."/meusarq/agenda/;"
29 Out 2013 23:43
30 Out 2013 09:58
cjp escreveu:2) na base AGTEL.DBF, ele não está localizando o nome Luiz, que existe na base; tanto procurando por Luiz, como por luiz, por LUIZ ou por uiz, em nenhuma hipótese ele acha;
$sql="SELECT * FROM ".$txtArquivo." WHERE UPPER(".$txtCampo.") LIKE '%".$txtPesquisa."%'";
cjp escreveu:Também gostaria de saber se existe como fazer consulta semelhante para campos que não são caracteres. Já verifiquei que a consulta funciona com caracteres, mas meio defeituosa. Exemplo: se procuro por 1000 num campo numérico, ele vai achar 1000, mas também vai achar 10000, 5100 etc. Idem para campos data. Se for possível fazer uma consulta específica, seria ótimo.