Ver Mensaje Individual
  #24 (permalink)  
Antiguo 17/04/2012, 16:08
Avatar de santris
santris
 
Fecha de Ingreso: agosto-2009
Ubicación: Sant Feliu de Llobregat
Mensajes: 955
Antigüedad: 17 años, 1 mes
Puntos: 66
Respuesta: Verificar si existen varios registros en una BD

Mira prueba este tal cual haber si te sirve:

Código PHP:
<?php
$correo1
='[email protected]';
$correo2='';
$condiciones = " 1 = 2";
if(!empty(
$correo1))
  
$condiciones .= " OR  integrante1 = '".$correo1."' OR integrante2 = '".$correo1."' OR integrante3 = '".$correo1."' OR integrante4 = '".$correo1."' OR  integrante5 = '".$correo1."'";
if(!empty(
$correo2))
  
$condiciones .= " OR  integrante1 = '".$correo2."' OR integrante2 = '".$correo2."' OR integrante3 = '".$correo2."' OR integrante4 = '".$correo2."' OR  integrante5 = '".$correo2."'";
$sql = "select * from proyecto where $condiciones";
echo 
$sql;
?>
Lo he probado y el resultado es este:

Código PHP:
select * from proyecto where 1 = 2 OR integrante1 = '[email protected]' OR integrante2 = '[email protected]' OR integrante3 = '[email protected]' OR integrante4 = '[email protected]' OR integrante5 = '[email protected]' 
__________________
Tu álbum de cromos online!!