php.de

Zurück   php.de > Webentwicklung > PHP Einsteiger > PHP Tipps 2006

 
 
LinkBack Themen-Optionen Thema bewerten
Alt 08.07.2006, 13:12  
bp158
Gast
 
Beiträge: n/a
Standard Problem und Frage zu Listenfeldauswertung ....

Hi,

irgendwie hab ich grad mal wieder 'n Brett vorm Kopf

Also ich hab hier ein Formular, wo zwei Listboxen (SELECT) sowie 15 Checkboxen existieren.

in den Listboxen kann man zwischen Werktagen (1-10) und Wochentagen (1-10) auswählen. Je nachdem was man dort auswählt, sollen die Checkboxen ausgewählt sein ...

Mein bisheriger Code zur Auswertung:

PHP-Code:
   $form_auftragsprioritaet_wtage $_POST["form_auftragsprioritaet_wtage"];
   
$form_auftragsprioritaet_atage $_POST["form_auftragsprioritaet_atage"];

     
     
$prio_auswahl_wt_array = array("-" => "Werktage""10wtage" => "10 Werktage, bis zum ".date("d.m.",$datum10),"09wtage" => "9 Werktage, bis zum "date("d.m.",$datum09), "08tage" => "8 Werktage, bis zum "date("d.m.",$datum08), "07tage" => "7 Werktage, bis zum "date("d.m.",$datum07), "06tage" => "6 Werktage, bis zum "date("d.m.",$datum06), "05tage" => "5 Werktage, bis zum "date("d.m.",$datum05), "04tage" => "4 Werktage, bis zum "date("d.m.",$datum04), "03tage" => "3 Werktage, bis zum "date("d.m.",$datum03), "02tage" => "2 Werktage, bis zum "date("d.m.",$datum02), "01tage" => "1 Werktag, bis zum "date("d.m.",$datum01));
     
$prio_auswahl_at_array = array("-" => "Wochentage""10atage" => "10 Wochentage, bis zum "date("d.m.",$arbeitstag10), "09atage" => "9 Wochentage, bis zum "date("d.m.",$arbeitstag09), "08atage" => "8 Wochentage, bis zum "date("d.m.",$arbeitstag08), "07atage" => "7 Wochentage, bis zum "date("d.m.",$arbeitstag07), "06atage" => "6 Wochentage, bis zum "date("d.m.",$arbeitstag06), "05atage" => "5 Wochentage, bis zum "date("d.m.",$arbeitstag05), "04atage" => "4 Wochentage, bis zum "date("d.m.",$arbeitstag04), "03atage" => "3 Wochentage, bis zum "date("d.m.",$arbeitstag03), "02atage" => "2 Wochentage, bis zum "date("d.m.",$arbeitstag02), "01atage" => "1 Wochentag, bis zum "date("d.m.",$arbeitstag01));
     
     
$prioritaets_auswahl_wtage "<SELECT name=\"form_auftragsprioritaet_wtage\">";
     foreach (
$prio_auswahl_wt_array as $k => $v)
       {
       if (
$k == $form_auftragsprioritaet_wtage)
         {
         
$prioritaets_auswahl_wtage .= "<OPTION value=\"".$k."\" selected>".$v."</OPTION>";
         }
        else
         {
         
$prioritaets_auswahl_wtage .= "<OPTION value=\"".$k."\">".$v."</OPTION>";
         }
       }
     
$prioritaets_auswahl_wtage .= "</SELECT>";
          
     
$prioritaets_auswahl_atage "<SELECT name=\"form_auftragsprioritaet_atage\">";
     foreach (
$prio_auswahl_at_array as $k => $v)
       {
       if (
$k == $form_auftragsprioritaet_atage)
         {
         
$prioritaets_auswahl_atage .= "<OPTION value=\"".$k."\" selected>".$v."</OPTION>";
         }
        else
         {
         
$prioritaets_auswahl_atage .= "<OPTION value=\"".$k."\">".$v."</OPTION>";
         }
       }
     
$prioritaets_auswahl_atage .= "</SELECT>";
     
     
// $prioritaets_auswahl_atage = "<SELECT name=\"form_auftragsprioritaet_atage\"><OPTION value=\"-\">Wochentage</OPTION><OPTION value=\"10atage\">10 Wochentage, bis zum ". date("d.m.",$arbeitstag10) ."</OPTION><OPTION value=\"09atage\">9 Wochentage, bis zum ". date("d.m.",$arbeitstag09) ."</OPTION><OPTION value=\"08atage\">8 Wochentage, bis zum ". date("d.m.",$arbeitstag08) ."</OPTION><OPTION value=\"07atage\">7 Wochentage, bis zum ". date("d.m.",$arbeitstag07) ."</OPTION><OPTION value=\"06atage\">6 Wochentage, bis zum ". date("d.m.",$arbeitstag06) ."</OPTION><OPTION value=\"05atage\">5 Wochentage, bis zum ". date("d.m.",$arbeitstag05) ."</OPTION><OPTION value=\"04atage\">4 Wochentage, bis zum ". date("d.m.",$arbeitstag04) ."</OPTION><OPTION value=\"03atage\">3 Wochentage, bis zum ". date("d.m.",$arbeitstag03) ."</OPTION><OPTION value=\"02atage\">2 Wochentage, bis zum ". date("d.m.",$arbeitstag02) ."</OPTION><OPTION value=\"01atage\">1 Wochentag, bis zum ". date("d.m.",$arbeitstag01) ."</OPTION></SELECT>";


        
$tag0 strtotime(now);
        
$tag1 strtotime("+1 days");
        
$tag2 strtotime("+2 days");
        
$tag3 strtotime("+3 days");
        
$tag4 strtotime("+4 days");
        
$tag5 strtotime("+5 days");
        
$tag6 strtotime("+6 days");
        
$tag7 strtotime("+7 days");
        
$tag8 strtotime("+8 days");
        
$tag9 strtotime("+9 days");
        
$tag10 strtotime("+10 days");
        
$tag11 strtotime("+11 days");
        
$tag12 strtotime("+12 days");
        
$tag13 strtotime("+13 days");
        
$tag14 strtotime("+14 days");


    if (
$form_auftragspriorität_atage != "-" AND $form_auftragsprioritaet_wtage == "-")
      {
      switch(
$form_auftragsprioritaet_atage)
         {
         case 
"-":
          break;
         case 
"10atage":     
          
$form_todo_check_field00 date("Y-m-d",$tag0);
          
$form_todo_check_field01 date("Y-m-d",$tag1);
          
$form_todo_check_field02 date("Y-m-d",$tag2);
          
$form_todo_check_field03 date("Y-m-d",$tag3);
          
$form_todo_check_field04 date("Y-m-d",$tag4);
          
$form_todo_check_field05 date("Y-m-d",$tag5);
          
$form_todo_check_field06 date("Y-m-d",$tag6);
          
$form_todo_check_field07 date("Y-m-d",$tag7);
          
$form_todo_check_field08 date("Y-m-d",$tag8);
          
$form_todo_check_field09 date("Y-m-d",$tag9);
          
$form_todo_check_field10 date("Y-m-d",$tag10);
          break;
         case 
"09atage":     
          
$form_todo_check_field00 date("Y-m-d",$tag0);
          
$form_todo_check_field01 date("Y-m-d",$tag1);
          
$form_todo_check_field02 date("Y-m-d",$tag2);
          
$form_todo_check_field03 date("Y-m-d",$tag3);
          
$form_todo_check_field04 date("Y-m-d",$tag4);
          
$form_todo_check_field05 date("Y-m-d",$tag5);
          
$form_todo_check_field06 date("Y-m-d",$tag6);
          
$form_todo_check_field07 date("Y-m-d",$tag7);
          
$form_todo_check_field08 date("Y-m-d",$tag8);
          
$form_todo_check_field09 date("Y-m-d",$tag9);
          
$form_todo_check_field10 "";
          break;
         case 
"08atage":     
          
$form_todo_check_field00 date("Y-m-d",$tag0);
          
$form_todo_check_field01 date("Y-m-d",$tag1);
          
$form_todo_check_field02 date("Y-m-d",$tag2);
          
$form_todo_check_field03 date("Y-m-d",$tag3);
          
$form_todo_check_field04 date("Y-m-d",$tag4);
          
$form_todo_check_field05 date("Y-m-d",$tag5);
          
$form_todo_check_field06 date("Y-m-d",$tag6);
          
$form_todo_check_field07 date("Y-m-d",$tag7);
          
$form_todo_check_field08 date("Y-m-d",$tag8);
          
$form_todo_check_field09 "";
          
$form_todo_check_field10 "";
          break;
         case 
"07atage":     
          
$form_todo_check_field00 date("Y-m-d",$tag0);
          
$form_todo_check_field01 date("Y-m-d",$tag1);
          
$form_todo_check_field02 date("Y-m-d",$tag2);
          
$form_todo_check_field03 date("Y-m-d",$tag3);
          
$form_todo_check_field04 date("Y-m-d",$tag4);
          
$form_todo_check_field05 date("Y-m-d",$tag5);
          
$form_todo_check_field06 date("Y-m-d",$tag6);
          
$form_todo_check_field07 date("Y-m-d",$tag7);
          
$form_todo_check_field08 "";
          
$form_todo_check_field09 "";
          
$form_todo_check_field10 "";
          break;
         case 
"06atage":     
          
$form_todo_check_field00 date("Y-m-d",$tag0);
          
$form_todo_check_field01 date("Y-m-d",$tag1);
          
$form_todo_check_field02 date("Y-m-d",$tag2);
          
$form_todo_check_field03 date("Y-m-d",$tag3);
          
$form_todo_check_field04 date("Y-m-d",$tag4);
          
$form_todo_check_field05 date("Y-m-d",$tag5);
          
$form_todo_check_field06 date("Y-m-d",$tag6);
          
$form_todo_check_field07 "";
          
$form_todo_check_field08 "";
          
$form_todo_check_field09 "";
          
$form_todo_check_field10 "";
          break;
         case 
"05atage":     
          
$form_todo_check_field00 date("Y-m-d",$tag0);
          
$form_todo_check_field01 date("Y-m-d",$tag1);
          
$form_todo_check_field02 date("Y-m-d",$tag2);
          
$form_todo_check_field03 date("Y-m-d",$tag3);
          
$form_todo_check_field04 date("Y-m-d",$tag4);
          
$form_todo_check_field05 date("Y-m-d",$tag5);
          
$form_todo_check_field06 "";
          
$form_todo_check_field07 "";
          
$form_todo_check_field08 "";
          
$form_todo_check_field09 "";
          
$form_todo_check_field10 "";
          break;
         case 
"04atage":     
          
$form_todo_check_field00 date("Y-m-d",$tag0);
          
$form_todo_check_field01 date("Y-m-d",$tag1);
          
$form_todo_check_field02 date("Y-m-d",$tag2);
          
$form_todo_check_field03 date("Y-m-d",$tag3);
          
$form_todo_check_field04 date("Y-m-d",$tag4);
          
$form_todo_check_field05 "";
          
$form_todo_check_field06 "";
          
$form_todo_check_field07 "";
          
$form_todo_check_field08 "";
          
$form_todo_check_field09 "";
          
$form_todo_check_field10 "";
          break;
         case 
"03atage":     
          
$form_todo_check_field00 date("Y-m-d",$tag0);
          
$form_todo_check_field01 date("Y-m-d",$tag1);
          
$form_todo_check_field02 date("Y-m-d",$tag2);
          
$form_todo_check_field03 date("Y-m-d",$tag3);
          
$form_todo_check_field04 "";
          
$form_todo_check_field05 "";
          
$form_todo_check_field06 "";
          
$form_todo_check_field07 "";
          
$form_todo_check_field08 "";
          
$form_todo_check_field09 "";
          
$form_todo_check_field10 "";
          break;
         case 
"02atage":     
          
$form_todo_check_field00 date("Y-m-d",$tag0);
          
$form_todo_check_field01 date("Y-m-d",$tag1);
          
$form_todo_check_field02 date("Y-m-d",$tag2);
          
$form_todo_check_field03 "";
          
$form_todo_check_field04 "";
          
$form_todo_check_field05 "";
          
$form_todo_check_field06 "";
          
$form_todo_check_field07 "";
          
$form_todo_check_field08 "";
          
$form_todo_check_field09 "";
          
$form_todo_check_field10 "";
          break;
         case 
"01atage":     
          
$form_todo_check_field00 date("Y-m-d",$tag0);
          
$form_todo_check_field01 date("Y-m-d",$tag1);
          
$form_todo_check_field02 "";
          
$form_todo_check_field03 "";
          
$form_todo_check_field04 "";
          
$form_todo_check_field05 "";
          
$form_todo_check_field06 "";
          
$form_todo_check_field07 "";
          
$form_todo_check_field08 "";
          
$form_todo_check_field09 "";
          
$form_todo_check_field10 "";
          break;
         }
      }


      if (isset(
$form_todo_check_field00) AND !empty($form_todo_check_field00))
        {
        
$todo_check_field_00 "<input type=\"checkbox\" name=\"form_todo_check_field00\" value=\""$form_todo_check_field00 ."\" checked>";
        }
       else
        {
        
$todo_check_field_00 "<input type=\"checkbox\" name=\"form_todo_check_field00\" value=\""date("Y-m-d",$tag0) ."\">";
        }
        
      if (isset(
$form_todo_check_field01) AND !empty($form_todo_check_field01))
        {
        
$todo_check_field_01 "<input type=\"checkbox\" name=\"form_todo_check_field01\" value=\""$form_todo_check_field01 ."\" checked>";
        }
       else
        {
        
$todo_check_field_01 "<input type=\"checkbox\" name=\"form_todo_check_field01\" value=\""date("Y-m-d",$tag1) ."\">";
        }
        
      if (isset(
$form_todo_check_field02) AND !empty($form_todo_check_field02))
        {
        
$todo_check_field_02 "<input type=\"checkbox\" name=\"form_todo_check_field02\" value=\""$form_todo_check_field02 ."\" checked>";
        }
       else
        {
        
$todo_check_field_02 "<input type=\"checkbox\" name=\"form_todo_check_field02\" value=\""date("Y-m-d",$tag2) ."\">";
        }
        
      if (isset(
$form_todo_check_field03) AND !empty($form_todo_check_field03))
        {
        
$todo_check_field_03 "<input type=\"checkbox\" name=\"form_todo_check_field03\" value=\""$form_todo_check_field03 ."\" checked>";
        }
       else
        {
        
$todo_check_field_03 "<input type=\"checkbox\" name=\"form_todo_check_field03\" value=\""date("Y-m-d",$tag3) ."\">";
        }
        
      if (isset(
$form_todo_check_field04) AND !empty($form_todo_check_field04))
        {
        
$todo_check_field_04 "<input type=\"checkbox\" name=\"form_todo_check_field04\" value=\""$form_todo_check_field04 ."\" checked>";
        }
       else
        {
        
$todo_check_field_04 "<input type=\"checkbox\" name=\"form_todo_check_field04\" value=\""date("Y-m-d",$tag4) ."\">";
        }
        
      if (isset(
$form_todo_check_field05) AND !empty($form_todo_check_field05))
        {
        
$todo_check_field_05 "<input type=\"checkbox\" name=\"form_todo_check_field05\" value=\""$form_todo_check_field05 ."\" checked>";
        }
       else
        {
        
$todo_check_field_05 "<input type=\"checkbox\" name=\"form_todo_check_field05\" value=\""date("Y-m-d",$tag5) ."\">";
        }
        
      if (isset(
$form_todo_check_field06) AND !empty($form_todo_check_field06))
        {
        
$todo_check_field_06 "<input type=\"checkbox\" name=\"form_todo_check_field06\" value=\""$form_todo_check_field06 ."\" checked>";
        }
       else
        {
        
$todo_check_field_06 "<input type=\"checkbox\" name=\"form_todo_check_field06\" value=\""date("Y-m-d",$tag6) ."\">";
        }
        
      if (isset(
$form_todo_check_field07) AND !empty($form_todo_check_field07))
        {
        
$todo_check_field_07 "<input type=\"checkbox\" name=\"form_todo_check_field07\" value=\""$form_todo_check_field07 ."\" checked>";
        }
       else
        {
        
$todo_check_field_07 "<input type=\"checkbox\" name=\"form_todo_check_field07\" value=\""date("Y-m-d",$tag7) ."\">";
        }

      if (isset(
$form_todo_check_field08) AND !empty($form_todo_check_field08))
        {
        
$todo_check_field_08 "<input type=\"checkbox\" name=\"form_todo_check_field08\" value=\""$form_todo_check_field08 ."\" checked>";
        }
       else
        {
        
$todo_check_field_08 "<input type=\"checkbox\" name=\"form_todo_check_field08\" value=\""date("Y-m-d",$tag8) ."\">";
        }
        
      if (isset(
$form_todo_check_field09) AND !empty($form_todo_check_field09))
        {
        
$todo_check_field_09 "<input type=\"checkbox\" name=\"form_todo_check_field09\" value=\""$form_todo_check_field09 ."\" checked>";
        }
       else
        {
        
$todo_check_field_09 "<input type=\"checkbox\" name=\"form_todo_check_field09\" value=\""date("Y-m-d",$tag9) ."\">";
        }
        
      if (isset(
$form_todo_check_field10) AND !empty($form_todo_check_field10))
        {
        
$todo_check_field_10 "<input type=\"checkbox\" name=\"form_todo_check_field10\" value=\""$form_todo_check_field10 ."\" checked>";
        }
       else
        {
        
$todo_check_field_10 "<input type=\"checkbox\" name=\"form_todo_check_field10\" value=\""date("Y-m-d",$tag10) ."\">";
        }
        
      if (isset(
$form_todo_check_field11) AND !empty($form_todo_check_field11))
        {
        
$todo_check_field_11 "<input type=\"checkbox\" name=\"form_todo_check_field11\" value=\""$form_todo_check_field11 ."\" checked>";
        }
       else
        {
        
$todo_check_field_11 "<input type=\"checkbox\" name=\"form_todo_check_field11\" value=\""date("Y-m-d",$tag11) ."\">";
        }
        
      if (isset(
$form_todo_check_field12) AND !empty($form_todo_check_field12))
        {
        
$todo_check_field_12 "<input type=\"checkbox\" name=\"form_todo_check_field12\" value=\""$form_todo_check_field12 ."\" checked>";
        }
       else
        {
        
$todo_check_field_12 "<input type=\"checkbox\" name=\"form_todo_check_field12\" value=\""date("Y-m-d",$tag12) ."\">";
        }
       
      if (isset(
$form_todo_check_field13) AND !empty($form_todo_check_field13))
        {
        
$todo_check_field_13 "<input type=\"checkbox\" name=\"form_todo_check_field13\" value=\""$form_todo_check_field13 ."\" checked>";
        }
       else
        {
        
$todo_check_field_13 "<input type=\"checkbox\" name=\"form_todo_check_field13\" value=\""date("Y-m-d",$tag13) ."\">";
        }

      if (isset(
$form_todo_check_field14) AND !empty($form_todo_check_field14))
        {
        
$todo_check_field_14 "<input type=\"checkbox\" name=\"form_todo_check_field14\" value=\""$form_todo_check_field14 ."\" checked>";
        }
       else
        {
        
$todo_check_field_14 "<input type=\"checkbox\" name=\"form_todo_check_field14\" value=\""date("Y-m-d",$tag14) ."\">";
        } 
Wenn ich Wochentage auswähle, dann werden die entsprechenden Checkboxen auch angewählt. Nur wenn ich Werktage auswähle, dann passiert bis jetzt noch nix (weiss noch nicht genau wie ich das mache).

Das was mich momentan stutzig macht ist, das wenn ich

PHP-Code:

    
if ($form_auftragspriorität_atage == "-" AND $form_auftragsprioritaet_wtage == "-")
      {
      echo 
"at / wt
"
;
      }

    if (
$form_auftragspriorität_atage == "-" AND $form_auftragsprioritaet_wtage != "-")
      {
      echo 
"at  &  <> wt 
"
;
      }

    if (
$form_auftragspriorität_atage != "-" AND $form_auftragsprioritaet_wtage != "-")
      {
      echo 
"<> at  &  <> wt 
"
;
      }

    if (
$form_auftragspriorität_atage != "-" AND $form_auftragsprioritaet_wtage == "-")
      {
      echo 
"<> at  &  wt 
"
;
      } 
reinhänge alles eigtnlich korrekt auswähle, er dann meistens die priorität bei atagen als <> anzeigt ...

Kann mir jemand helfen ??

Thx

BP
 
Sponsor Mitteilung
PHP Code Flüsterer

Registriert seit: 21.08.2005
Beiträge: 4682
PHP-Kenntnisse:
Fortgeschritten

Alt 10.07.2006, 13:19  
Erfahrener Benutzer
 
Registriert seit: 09.03.2005
Beiträge: 219
webbi
Standard

An dem Code solltest du so nicht weiterarbeiten.
Schonmal was von Schleifen gehört?

Vor allem:
case "10atage", case "9atage", ...
sollte man in 10-15 Zeilen unterbringen können, nicht in über 100...

Arrays wären hier auch angebracht.
Beschäftige dich erstmal ein wenig damit, vielleicht löst sich das Problem dann schon von selbst, aber früher oder später wirst du dein Script sowiso umbauen müssen wenn du hiermit weiterarbeitest.
webbi ist offline  
Alt 10.07.2006, 22:37  
bp158
Gast
 
Beiträge: n/a
Standard

Hi,

danke für Deine Anmerkungen. Könntest Du mir evtl. ein paar tips geben (speziell wie ich es bei den Werktagen anstellen könnte, das diejenigen ausgewählt sind jenachdem wieviel tage man wählt) ?? Das Auswählen werde ich wahrscheinlich per funktion machen ...

Thx

BP
 
 


Themen-Optionen
Thema bewerten
Thema bewerten:

Forumregeln
Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are an
Gehe zu

Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
mod_rewrite Problem mit encodierten URLs R4v3r Server, Hosting und Workstations 0 25.07.2008 18:42
[Erledigt] Galerie Problem... coraplanet PHP Tipps 2008 4 06.06.2008 13:42
Timestamp problem phrain PHP Tipps 2008 2 04.04.2008 09:41
MATCH .... AGAINST ... Problem Denise Datenbanken 4 21.03.2007 20:05
datensätze defekt oder problem mit dem einlesen? Ministry Datenbanken 4 06.07.2006 18:42
problem!!! PHP Tipps 2006 6 08.02.2006 11:06
[Erledigt] wieder ein Problem bei phpmailer und smtp PHP Tipps 2006 24 07.02.2006 01:07
[Erledigt] Problem mit Backslash Patrick Schwarz PHP Tipps 2005-2 5 26.07.2005 09:54
[Erledigt] Problem mit User/Group: nobody(99)/99 Server, Hosting und Workstations 3 09.07.2005 15:31
[Erledigt] File download &gt; kleines Problem PHP Tipps 2005 3 11.05.2005 23:11
[Erledigt] Problem bei Massenmails versenden mit der Funktion mail PHP-Fortgeschrittene 3 19.01.2005 13:36
UTF8-XML ... Fehler beim auslesen PHP Tipps 2005 40 15.01.2005 21:28
Smarty und PHP-Skript Problem PHP Tipps 2004-2 2 03.12.2004 22:27
Problem mit alter JavaScript-Funktion woods PHP Tipps 2004 1 13.08.2004 13:34
Login Problem PHP Tipps 2004 4 04.06.2004 18:46


Alle Zeitangaben in WEZ +2. Es ist jetzt 18:10 Uhr.




Powered by vBulletin® Version 3.7.2 (Deutsch)
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Aprilia-Forum, Aquaristik-Forum, Liebeskummer-Forum, Zierfisch-Forum, Geizkragen-Forum

Creative Commons License
Dieser Inhalt ist unter einer Creative Commons-Lizenz lizenziert.