Servus Jungs,
ich wollte mal Fragen ob es bei meinem Folgen Code eine bessere anordnung gibt. Grund: ich muss vieles zwei mal schreiben:
[PHP]
if($action == „add“)
{
echo $navi;
if(isset($save))
{
$check = empty($_POST['opponent']) || empty($_POST['maps']) || empty($_POST['result1']) || empty($_POST['result2']);
if($check)
{
if(empty($_POST['opponent'])) $error="Bitte geben Sie einen Gegner an";
elseif(empty($_POST['maps'])) $error="Bitte geben Sie Maps an";
elseif(empty($_POST['result1'])) $error="Bitte geben Sie ein Ergebnis an";
$result=query("SELECT catID, name FROM ".PREFIX."_matches_cats");
$data = array();
if(mysql_num_rows($result))
{
while($data[] = mysql_fetch_assoc($result));
{
array_pop($data);
$config = array();
$config['name']='demolist';
$config['size']=1;
$config['selected']=$_POST['category'];
foreach($data as $key)
{
$selected = ($config['selected'] == $key['catID'])
? 'selected '
: '';
$categories.= '<option value="'.$key['catID'].'"'.$selected.'>'.$key['name'].'</option>';
}
}
}
else
{
$categories .="<option value=\"0\">keine Kategorien</option>";
}
$xonx=check($_POST['xonx'],1,6,1);
$days=check($_POST['date_day'],1,32,2);
$months=check($_POST['date_month'],1,12,2);
$hours=check($_POST['time_hour'],0,24,2);
$minutes=check($_POST['time_minute'],0,60,2);
$years=check($_POST['date_year'],2004,2008,2);
echo show("error", array("error" => $error));
echo show("matches_add", array("post_categories" => $categories,
"post_opponent" => $_POST['opponent'],
"post_opponent_hp" => $_POST['opponent_hp'],
"post_description" => $_POST['description'],
"post_day" => $days,
"post_month" => $months,
"post_hour" => $hours,
"post_minute" => $minutes,
"post_year" => $years,
"post_maps" => $_POST['maps'],
"post_lineup" => $_POST['lineup'],
"post_xonx" => $xonx,
"post_result1" => $_POST['result1'],
"post_result2" => $_POST['result2']));
}
else
{
$date=mktime($_POST['time_hour'], $_POST['time_minute'], 0, $_POST['date_month'], $_POST['date_day'], $_POST['date_year']);
query("INSERT INTO ".PREFIX."_matches (catID, opponent, opponent_hp, date, xonx, maps, players, description, result1, result2) VALUES (".$_POST['category'].", '".$_POST['opponent']."', '".$_POST['opponent_hp']."', ".$date.", '".$_POST['xonx']."', '".$_POST['maps']."', '".$_POST['lineup']."', '".$_POST['description']."', '".$_POST['result1']."', '".$_POST['result2']."')");
echo "<meta http-equiv=\"refresh\" content=\"0; url=index.php?site=matches\">";
}
}
else
{
$result=query("SELECT catID, name FROM ".PREFIX."_matches_cats");
$data = array();
if(mysql_num_rows($result))
{
while($data[] = mysql_fetch_assoc($result));
{
array_pop($data);
$config = array();
$config['name']='demolist';
$config['size']=1;
$config['selected']=$_POST['categories'];
foreach($data as $key)
{
$selected = ($config['selected'] == $key['catID'])
? 'selected '
: '';
$categories.= '<option value="'.$key['catID'].'"'.$selected.'>'.$key['name'].'</option>';
}
}
}
else
{
$categories .="<option value=\"0\">keine Kategorien</option>";
}
$xonx=check($_POST['xonx'],1,6,1);
$days=check($_POST['date_day'],1,32,2);
$months=check($_POST['date_month'],1,12,2);
$hours=check($_POST['time_hour'],0,24,2);
$minutes=check($_POST['time_minute'],0,60,2);
$years=check($_POST['date_year'],2004,2008,2);
echo show("matches_add", array("post_categories" => $categories,
"post_opponent" => $_POST['opponent'],
"post_opponent_hp" => $_POST['opponent_hp'],
"post_day" => $days,
"post_month" => $months,
"post_hour" => $hours,
"post_minute" => $minutes,
"post_year" => $years,
"post_description" => $_POST['description'],
"post_maps" => $_POST['maps'],
"post_lineup" => $_POST['lineup'],
"post_xonx" => $xonx,
"post_result1" => $_POST['result1'],
"post_result2" => $_POST['result2']));
}
}
[/PHP]
Mit Anordnung meine ich ander IF anfragen z.b.