Hello, good evening, everyone.
This is my first question on the forum and I would like to resolve a problem with my small web application.
This is a final semester work of my course, and I need to create a small system of product registration, using the functions of Insert, Delete, Change and List with PHP
and MySQL
.
Before detailing the problem, I'll specify how the system is.
When you register a new product, a modal
is opened, and then enter all data for the product. After inserting, the registered product is added to div
, where it contains a box
with the image and product information.
I've created a input
for product search, but when I enter the name of a product, it doubles .
<div id="Conteudo">
<form>
<input id="Pesquisa" type="search" name="Pesquisar">
<input id="Buscar" type="submit" name="Enviar" />
<!-- Código PHP -->
</form>
<div id="Produto">
<!-- Descrição do produto -->
<!-- Código PHP para exibir Produto após seu registro -->
</div>
</div>
<!-- Código PHP que realiza a busca no banco e lista o resultado -->
<?php
if(isset($_POST['Enviar'])){
$Pesquisar = $_POST['Pesquisar'];
if($Pesquisar != NULL){
$request = mysql_query("SELECT * FROM 'banco'.'tabela' WHERE nome = '$Pesquisar' ");
echo "
<div id="Produto">
<!-- Conteúdo -->
</div>
";
?>
I have simplified the code since there are many lines considering the entire form, PHP
and MySQL
. I'm pretty sure the problem is because the PHP
codes are in different places. I came to research more about it and saw solutions that worked with OOP
.
I want to delve deeper into this paradigm. However, I need your help in completing this work.
This is the problem: When searching, instead of just displaying what was requested, it duplicates the search and gets out of the layout (I think that% different locations).
Please forgive me the length of the question. Thanks in advance for your attention.