Hello to everyone I need make a select from many tables, like this: PHP: SELECT * FROM clientes,coches,vendedores WHERE clientes.nif="$nif" or coches.matricula ="$matricula" or vendedores.nif="$nif" But i need that the BD show only the register founded, and right now it show all registers. I need this for one input text for search registers in the BD. Thank you
I mean that if the select found one register, for example: cliente.nif shows only that register, because now its load in the array registers from the 3 tables: PHP: $buscar = $_GET['buscar'];$resultado = mysql_query ("SELECT * FROM vehiculos,clientes,vendedores WHERE vehiculos.matricula = '$buscar' or clientes.nif='$buscar' or vendedores.nif='$buscar' limit 1");$ext=substr($foto1, -4);$observaciones=nl2br($observaciones); //Esto es para respetar los saltos de linea.while ($registro = mysql_fetch_row($resultado)) { $foto1 = "$ruta_img"."$registro[2]"; if (!empty($foto1)){ $foto1 = "<img src=$foto1 class='fotito'>"; } ?><a href=panel.php?modulo=vehiculo_uno&idv=<?php echo $registro[0];?>> <div id="registro_linea"> <ul> <li>Fecha de alta: <?php echo $registro[1];?></li> <li>Número Chasis:<?php echo $registro[3];?></li> <li>Marca: <?php echo $registro[4];?></li> <li>Modelo: <?php echo $registro[5];?></li> <li>Matricula: <?php echo "$registro[6] | ". "Fecha Matricula: $registro[7]";?></li> <li>Kilómetros: <?php echo $registro[8];?></li> <li>Precio de compra:<?php echo $registro[9];?></li> <li>Precio de venta: <?php echo $registro[10];?></li> <li>Situación: <?php echo $registro[13];?></li> </ul> <?php echo $foto1;?> </div> </a> <ul> <h2>DATOS DEL CLIENTE</h2> <li>Fecha de Operación: <?php echo $registro[10];?></li> <li>NIF/CIF:<?php echo $registro[1];?></li> <li>Nombre:<?php echo "$registro[2]"."$registro[3]";?></li> </ul> In this case $register[2] could to be cliente.nif and could be coches.matricula but if match cliente.nif if exist the script return vehiculo.matricula too, its weird, i dont know if i am explainig well...
thank you Falko, i know that is very hard to explain my trouble with that code for two reasons: one i dont know speak well english and two always is dificult to explain things like that.... My task is make a search form in many tables and that only return the askeds values. Example i make: select * from customers, cars, providers where customers.id="$search" or cars.num_plate="$search" or providers.id = "$search" HTML: <label for="Search">Search for Number Plate, Identification Personal, or Customer Code</label> <input type="text" name="search" placeholder="N. Plate - Ident." /> Returns something like (for customer match): Id: 123456789ABC Name: Pepito Perez ......... ........ And the search returns something like this for coches (cars) match: N. Plate: 0000ZZZ Marca: BMW Modelo: 325ci e92 Right now the query returns something like this: N. Plate: 0000ZZZ Marca: BMW Modelo: 325ci e92 Id: 123456789ABC Name: Pepito Perez Good anyway i will try your tip, thanks althoug if you can i would like so much to know how i can to do that. Thank you very much Falko (der komisar