Habe folgenden Code:
$sSQL = "SELECT MAX(atach_nr) AS atach_nr FROM atach_data WHERE untersuch_id=$untersuch_id AND atach_type=$a";
$rResult = mysql_query($sSQL);
$cResult = @mysql_num_rows($rResult);
$dResult = @mysql_fetch_row($rResult);
if (!$dResult[0])
$nr = 1;
else
$nr = $dResult[0]+1;