Mysql
 sql >> Datenbank >  >> RDS >> Mysql

PHP MySQL Mehrfachsuchabfrage mit Option / HTML-Formular-Tags auswählen

HTML

<select multiple name="location[]" size="2">

PHP

$w     = array();
$where = '';
foreach ($_POST['location'] as $loc){
  $loc = mysql_real_escape_string($loc);
  $w[] = "location = '$loc'";
}
if (!empty($_POST['type'])){
  $w[] = "type LIKE '%".mysql_real_escape_string($_POST['type'])."%'";
}
if ($w) $where = implode(' OR ',$w);