Que tal amigos,
Tengo un script el cual busca en una tabla de una base de datos, el problema surge cuando quiero hacer una consulta de dos tablas distintas a la vez
Espero me pueda ayudar,
Les dejo el código:
bd: rokito
//Esta tabla es la que busca el codigo que esta abajo
CREATE TABLE `laptop` (
`id_lap` INT(11) NOT NULL AUTO_INCREMENT,
`marcal` VARCHAR(12) NOT NULL,
`modelol` VARCHAR(15) NOT NULL,
`n_seriel` VARCHAR(20) NOT NULL,
`micro` VARCHAR(25) NOT NULL,
`disco_duro` VARCHAR(6) NOT NULL,
`memoria_Ram` VARCHAR(6) NOT NULL,
PRIMARY KEY (`id_lap`)
) ENGINE=InnoDB;
///Esta tabla es la que se requiere que tambien que busque junto con la anterior
CREATE TABLE `usuarios` (
`iduser` INT(11) NOT NULL AUTO_INCREMENT,
`nombre` VARCHAR(15) NOT NULL,
`App` VARCHAR(15) NOT NULL,
`Apm` VARCHAR(15) NOT NULL,
`ciudad` VARCHAR(15) NOT NULL,
`cod_post` VARCHAR(15) NOT NULL,
`id_lap` INT(11) NOT NULL,
PRIMARY KEY (`iduser`),
INDEX(id_lap),
FOREIGN KEY(id_lap) REFERENCES laptop (id_lap)
ON UPDATE RESTRICT
) ENGINE=InnoDB;
____________________________________________________
buscajax.php
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<html>
<head><title>Buscador</title>
<script type="text/javascript" src="ajax.js"></script>
<link rel="stylesheet" type="text/css" href="estilos.css" />
</head>
<body>
<center>
<h1><b> LAPTOP´S </b></h1>
</center>
<center>
BUSCAR <input type="text" id="bus" name="bus" onkeyup="loadXMLDoc()" required />
<div id="myDiv"></div>
</center>
</body>
</html>
__________________________________________________________
conexion.php
<?php
function conexion(){
if (!$con){
}
return($con);
}
?>
__________________________________________________________
proc.php
<?php include 'conexion.php';
$qwerty = $_POST['qwerty'];
$con=conexion();
$sql="SELECT * FROM laptop WHERE CONCAT (id_lap,' ',marcal,' ',modelol,' ',n_seriel,' ',micro,' ',disco_duro,' ',memoria_Ram ) LIKE '%".$qwerty."%'";
}
echo '<b>No hay sugerencias</b>';
}else{
echo '<b>Sugerencias:</b><br />';
echo '<b></b><br />';
echo "<table border='1'>
<tr>
<th>ID LAPTOP</th>
<th>MARCA</th>
<th>MODELO</th>
<th>NUMERO DE SERIE</th>
<th>MICROPROCESADOR</th>
<th>DISCO DURO</th>
<th>MEMORIA RAM</th>
</tr>";
echo "<tr>";
echo "<td><a href='modificalap.php?id_lap".$fila['id_lap']."'>".$fila['id_lap']."</a></td> \n";
echo "<td>" . $fila['marcal'] . "</td>";
echo "<td>" . $fila['modelol'] . "</td>";
echo "<td>" . $fila['n_seriel'] . "</td>";
echo "<td>" . $fila['micro'] . "</td>";
echo "<td>" . $fila['disco_duro'] . "</td>";
echo "<td>" . $fila['memoria_Ram'] . "</td>";
echo "</tr>";
}
}
?>
________________________________________________
ajax.js
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","proc.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("qwerty="+n);
}
_________________________________________________________
estilos.css
div
{
margin-top: 10px;
border-style:dashed;
width: 1500px;
height: 1500px;
background-color:#F0FFF0;
text-align: left;
color:#00008B;
padding:10px 10px;
}
body{
color:#696969;
font-family:Arial,Helvetica,sans-serif;
}
[/color]