Hallo robertroth,
ok, ich glaube ich habe es. Meine Test war erfolgreich:
function kundenUebersicht($mysqli, $UserCode=false, $UserRechte=false) {
$select = "SELECT
kd_id,
kd_code,
kd_userID,
kd_status,
kd_firma,
kd_anrede,
kd_name,
kd_vorname,
kd_zusatz,
kd_strasse,
kd_plz,
kd_ort,
kd_telefon,
kd_handy,
kd_fax,
kd_email,
kd_url,
kd_packstationen,
kd_notiz,
kd_ip,
kd_datum,
ud_Uid,
ud_vorname,
ud_name,
user_code,
user_type
FROM web_kunden
LEFT JOIN web_users_detail ON web_users_detail.ud_Uid = web_kunden.kd_userID
LEFT JOIN web_users ON web_users.user_code = web_kunden.kd_userID";
if ($UserRechte == 'mitarbeiter') {
if ($UserCode) {
$stmt = $mysqli->prepare($select . " WHERE kd_userID =?" );
$stmt->bind_param("s", $UserCode);
} else {
$stmt = $mysqli->prepare($select);
}
} else {
$stmt = $mysqli->prepare($select);
}
$stmt->execute();
[.....]