I am making a simple system for my business everything is going well until now that I get stuck, I hope you can help me I would be grateful enough, I explain a bit of my code and its function first.
I have this input that searches for the products in my database and displays them in a table.
ventasgen.php
<center>
Buscar producto por: <B>NOMBRE</B> o <B>CODIGO</B> <br><br>
<input type="text" id="bus" name="bus" onkeyup="loadXMLDoc()" required autofocus/>
<br><br>
<div id="myDiv"></div>
</center>
<br><br>
<div class="row-fluid sortable">
<div class="box span12">
<div class="box-header" data-original-title>
<h2><i class="icon-usd"></i><span class="break"></span>PRODUCTOS AGREGADOS</h2>
<!--<div class="box-icon">
<a href="add_new_compra.php"><i class="halflings-icon white plus"></i>
<h7 style="color: white;"" >XXXXX</h7>
</a>
</div>-->
</div>
<div class="box-content">
<table border="1">
<thead>
<tr>
<th>ID</th>
<th>Nombre Producto</th>
<th>Unidad Producto</th>
<th>Stock</th>
</tr>
</thead>
<tbody>
<tr>
<td>Aqui aparezca el id del producto</td>
<td>Aqui aparezca el nombre del producto</td>
<td>Aqui aparezca la unidad del producto</td>
<td>Aqui aparezca el stock</b></center></td>
</tr>
</tbody>
</table>
</div>
</div><!--/span-->
</div><!--/row-->
my ajax_concuerdan.js file
function loadXMLDoc()
{
var xmlhttp;
var n=document.getElementById('bus').value;
if(n==''){
document.getElementById("myDiv").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST","ventasgenBUSCAR.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("q="+n);
}
and my file salesgenBUSCAR.php
<?php
@session_start();
error_reporting(E_ALL ^ E_DEPRECATED);
include("includes/connection1.php");
$q=$_POST['q'];
$res=mysqli_query($conn,"select * from 'tblproducts'
where nombre_producto LIKE '".$q."%'
OR id_producto LIKE '".$q."%'
OR CONCAT(nombre_producto,' ',unidad_producto) LIKE '".$q."%'
");
if(mysqli_num_rows($res)==0){
echo '<b>¡ NO EXISTEN PRODUCTOS CON ESA BUSQUEDA !</b>';
?>
<!DOCTYPE HTML>
<CENTER>
<br>
AGREGA EL PRODUCTO EN LA SECCION DE PRODUCTOS</a>
</CENTER>
<?php
}else{
echo '<b>Seleccionar producto:</b><br><br>';
?>
<!DOCTYPE HTML>
<table border="1px">
<tr>
<th>PRODUCTO </th>
<th>PRESENTACION</th>
<th></th>
</tr>
<?php while($fila=mysqli_fetch_array($res)){?>
<tr>
<td><?php echo $fila['nombre_producto']; ?> </td>
<td align="center"><?php echo $fila['unidad_producto']; ?></td>
<td><img src="img/add.png" width="20px" height="20px">
</tr>
<?php }?>
</table>
</html>
<?php } ?>
all this generates a page that when writing the name of the product appears a table with the same or similar products that there are, like the image that I attached ...
**
My question is how can I do that by clicking on the green plus sign of each product that I have in the table are added in the table below ....
**
Thank you very much for your time and reply greetings.