2.)sind alle felder leer, ist auch $where empty ... also ein if um implode mit der db-abfrage.(?)
zu 1. wirst du im forum was finden, vielleicht reguläre ausdrücke ...
$bla3 = trim($_POST['hersteller']);
if(!empty($bla3))
$where[]=" hersteller = '".$_POST['hersteller']."' ";
$bla3 = trim($_POST['hersteller']);
$bla3 = str_replace(" ","",$bla3);
if(!empty($bla3))
$where[]=" hersteller = '".$_POST['hersteller']."' ";
$bla3 = "ghds gsdhg hsgdh ";
echo str_replace (" ","",$bla3);
EDIT:
hmm ... langsam, wie immer
<? // db_ausgabe.php
include("mysql_connect.php3");
include("mysql_func.php3");
$_POST['geraet'] = trim($_POST['geraet']);
$_POST['geraet'] = str_replace (" ","",$_POST['geraet']);
if(!empty($_POST['geraet']))
$where[]=" geraet = '".$_POST['geraet']."' ";
$_POST['bestellnummer'] = trim($_POST['bestellnummer']);
$_POST['bestellnummer'] = str_replace (" ","",$_POST['bestellnummer']);
if(!empty($_POST['bestellnummer']))
$where[]=" bestellnummer = '".$_POST['bestellnummer']."' ";
$_POST['hersteller'] = trim($_POST['hersteller']);
$_POST['hersteller'] = str_replace (" ","",$_POST['hersteller']);
if(!empty($_POST['hersteller']))
$where[]=" hersteller = '".$_POST['hersteller']."' ";
$_POST['modell'] = trim($_POST['modell']);
$_POST['modell'] = str_replace (" ","",$_POST['modell']);
if(!empty($_POST['modell']))
$where[]=" modell = '".$_POST['modell']."' ";
$_POST['chassis'] = trim($_POST['chassis']);
$_POST['chassis'] = str_replace (" ","",$_POST['chassis']);
if(!empty($_POST['chassis']))
$where[]=" chassis = '".$_POST['chassis']."' ";
$_POST['name'] = trim($_POST['name']);
$_POST['name'] = str_replace (" ","",$_POST['name']);
if(!empty($_POST['name']))
$where[]=" name = '".$_POST['name']."' ";
$str_where = ' WHERE ' . implode(" AND ",$where);
$sql="SELECT geraet, bestellnummer, hersteller, modell, chassis, fehler, loesung, spoint, name, email, datum
FROM $tabelle $str_where";
If ($res=send_sql($db,$sql)) {
echo "<br><br><h1>Die Datenabfrage wurde ausgeführt</h1><br><br>";
}
tab_out($res);
?>
<?php
//postvars auslesen,überprüfen
$tr = "=";
$ts = "<>";
$parr = $_POST;
array_pop ($parr);
foreach ($parr as $var)
{
$i ++;
if(!empty($var))
{
switch (key($parr))
{
case 'bildurl':
$str = key($parr).$ts."'".$var."' AND ";
break;
case 'usersession':
$str = key($parr).$ts."'".$var."' AND ";
break;
case 'aler':
$str = key($parr)." ".$var." ";
break;
case 'alterbis':
$str = " ".$var." AND ";
break;
default:
$str = key($parr).$tr."'".$var."' AND ";
break;
}
$where[$i] = $str;
}
next($parr);
}
foreach($where AS $a) $string .= $a;
$l=strlen ($string);
$max = $l-4;
$where_str = substr($string, 0, $max);
$wherestr = ' WHERE ' . $where_str;
//abfrage
$sqluser = "SELECT * FROM flirt $wherestr";
$userdet = mysql_query($sqluser, $connect);
//echo "suchstring: $sqluser"; ** query überprüfen
//** nur eine testausgabe / unformatiert
while ($kon=mysql_fetch_array ($userdet))
{
echo "<br>$kon[name]";
echo "<img src=\"$kon[bildurl]\">";
}
?>
Kommentar