0
I need to check if a line is duplicated in mine TXT
how do I do?
<?php
$divisao = "1000000000000";
$linha = file("clientes/clientes.txt"); //Abre o banco de dados
$total = count($linha); //Conta as linhas
$paginas = ceil($total/$divisao)-1; //Faz a divisão
if(!$pagina='$pagina;' ){$pagina = "0";}
else if(!is_numeric($pagina)){$pagina = "0";}
else if($pagina > $paginas){$pagina = "0";}
else{$pagina = $pagina;}
if($total<=0){
echo "<P><DIV style=\"font-family:arial; font-size:14px; color:#999; text-align:center; margin-left:0 auto;\">Sem clientes para exibir!</DIV>";
}
$inicio = $pagina*$divisao;
$final = $inicio+$divisao;
$final = ($final > $total) ? $total : $final;
$linha = array_reverse($linha);
for ($i = $inicio; $i < $final; $i++){
list($dado1,$dado2,$dado3,$dado4,$dado5,$dado6) = explode("|",$linha[$i]);
echo "<form method=\"POST\" action=\"form.php\" onSubmit=\"if(!confirm('Deseja realmente continuar o pedido?')){return false;}\">";
echo "<tr><td>";
echo "<div id=\"div-clientes\">";
echo "<span style=\"display:none;\">$dado2</span>";
echo "<input type=\"text\" name=\"id\" value=\"$dado1\" id=\"campo_cads_id\" readonly=\"true\">";
echo "<input type=\"text\" name=\"data\" value=\"$dado6\" id=\"campo_cads_data\" readonly=\"true\">";
echo "<input type=\"text\" name=\"telefone\" value=\"$dado2\" id=\"campo_cads_tel\">";
echo "<input type=\"text\" name=\"nome\" value=\"$dado3\" id=\"campo_cads\">";
echo "<input type=\"text\" name=\"endereco\" value=\"$dado4\" id=\"campo_cads_end\">";
echo "<input type=\"text\" name=\"referencia\" value=\"$dado5\" id=\"campo_cads\">";
?>
Example of txt data
DADO1|DADO2|DADO3|DADO4|DADO5|DADO6|
DADO1|DADO2|DADO3|DADO4|DADO5|DADO6|
DADO1|DADO2|DADO3|DADO4|DADO5|DADO6|
I need you to check example the dado2
with the dado2
next line and tell if it’s duplicated?
If you tried any code?
– novic
For example here you can read the file https://imasters.com.br/artigo/1134/php/php-lendo-um-arquivo-txt?trace=1519021197&source=single
– novic
Possible duplicate of I have a BD in txt as I check if any stored data is duplicated and display?
– Rafael Mena Barreto
My code is already listing txt thus data list($dado1,$dado2,$dado3,$dado4,$dado5,$dado6) and inside txt thus: dado1 | dado2 | dado3 | dado4 | dado5 | dado6 |
– Rafa
missing file example!?
– novic
DADO1|DADO2|DADO3|DADO4|DADO5|DADO6|
– Rafa
I paste an example with 3 lines (in question) and one repeating and is to do what when repeat? (See the question has to have more detailed) I can even help you from that.
– novic
I edited the question I put the example! Sorry I’m new to this forum!
– Rafa
@Rafa is just the date2 or just check in the second column ?
– novic
Yes friend only the data2
– Rafa
I managed to do to check if there is the data2 but I wanted to see if this duplicate understands?
– Rafa
vc can use the in_array($given, $array) and check if the data is in the array, but the thing I see already has technical error when the guy comments "opens the DATABASE" with the file fopen... vc know that if your site is on, even by google da to find your "database" right?
– Michel Simões
I am using in host place to register customers of a pizzeria, with this only I have access! But how I use this function you mentioned?
– Rafa
I understand just create a new array and scan the list summing.
– novic
How do I do it buddy can make the code for me?
– Rafa
???????????????
– Rafa