2
Well, I created a search script in PHP, however, it does not display results, and also does not display errors.
Phomularius
<form class="navbar-form navbar-right" method="post" action="pesquisa_card.php">
<div class="form-group">
<input type="text" class="form-control" placeholder="Pesquisar" name="search-text" maxlength="255">
</div>
<button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search"></span><span class="sr-only">Buscar</span></button>
</form>
Search_card.php
<?php
require("components/header.php");
require("php-scripts/conecta.php");
require("php-scripts/banco-cadastros.php");
$busca = $_POST["search-text"];
$buscados = pesquisaCards($conexao, $busca);
foreach ($buscados as $encontrado) {
?>
<div>
<!-- <?= $card['id'] ?> -->
<div class="thumbnail">
<img src="<?= $encontrado['link_image'] ?>" alt="imagem de <?= $encontrado['card_name'] ?>">
<div class="caption">
<h3><?= $encontrado['card_name'] ?></h3>
<p><?= $encontrado['effect_description'] ?></p>
<p class="btn-holder"><a href="#" class="btn btn-info" role="button">Detalhes</a> <a href="#" class="btn btn-danger" role="button">Excluir</a></p>
</div>
</div>
</div>
<?php
}
require("components/footer.php");
Search function, pulled by the database.php
function pesquisaCards($conexao, $busca){
$buscados = array();
$resultado = mysqli_query($conexao, "select C.id, C.card_name, C.monster_lrl, C.link_image, C.effect_description, C.card_atk, C.card_def, C.quantity, E.edition_name, E.edition_code, S.card_status_desc, A.kind_attribute, K.kind_name, M.kind_monster_name from card C inner join card_editions E on E.id = C.id_card_edition inner join kind_attributes A on A.id = C.id_kind_attributes inner join kind_card K on K.id = C.id_kind_card inner join kind_monster M on M.id = C.id_kind_monster inner join card_status S on S.id = C.id_card_status where (('card_name' like '%".$busca."%') or ('effect_description' like '%".$busca."%') or ('edition_name' '%".$busca."%') or ('edition_code' '%".$busca."%') or ('kind_attribute' '%".$busca."%') or ('kind_name' '%".$busca."%') or ('kind_monster_name' '%".$busca."%'))");
while($encontrado = mysqli_fetch_assoc($resultado)){
array_push($buscados, $encontrado);
};
return $buscados;
};
Connection
$conexao = mysqli_connect("localhost", "root", "", "cardsystem");
- I was able to correct the first error, in which no value returned, because there were spaces in the query, between the concatenations, which were counted as part of the search. However, it still does not return any value when searching for the records, and if I do not write anything, it returns all the values of the database, showing no errors
probably the error this in the query also checks if you have data corresponding to that query
– 13dev
I checked, I have all the data, so much that I played in mysql and was not pointed out any error, but also returned no record
– Murilo Melo
try adding records and see if it works in php
– 13dev
It is good always before you put SQL code to run through the put application to run in the database directly to check whether it returns data or syntax errors.
– Claudio Ramos de Oliveira
@Claudioramosdeoliveira, already realized this, but it does not return errors, and also does not return values
– Murilo Melo
@13dev as add records ?
– Murilo Melo
@Murilogambôa add records in mysql to have inputs in php
– Otto
there are records, when entering the query in mysql, I search for "Kaiju", and I have 8 different "Kaiju" records
– Murilo Melo