Select Option aus Datenbank

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Select Option aus Datenbank

    hy leute!

    habe folgendes problem .. egal bei welchem script ichs probiere dass ich den wert der in der datenbank steht als selected wert rausbekomm!

    könnt ihr mir da weiterhelfen.. ich brings einfach nicht zusammen.. nicht bei A: und nicht bei B:

    was ich zusammenbringe ist dass mir der letzte wert als selected ausgegeben wird aber nie der wirkliche wert..


    A:

    PHP Code:
    " <select name=\"artoptid\">
            <option value=\"0\">Option</option> "
    ;
    $sqlbefehl"Select * FROM $tab_artopt where artid = $artikel[artid]";
    $getopt mysql_query($sqlbefehl$serverid);
     if (
    mysql_num_rows($getopt) > ) {
     echo 
    " <select name=\"artoptid\">";
    while ( 
    $opt mysql_fetch_array ($getopt)) {
            echo 
    "<option value=\"$opt[id]\" ";
            if (
    $artikel[bopt] != "") echo " selected ";
            echo 
    ">$opt[artopt] - ".ShopWaehrungFormat($opt[artpreis])."</option>";
        }}
    echo 
    "</select> "

    B:

    PHP Code:
       $sqlbefehl"Select * FROM $tab_artopt where artid = $artikel[artid]";

                
    $getopt mysql_query($sqlbefehl$serverid);

                 echo 
    mysql_error();

              if (
    mysql_num_rows($getopt) > ) {

                  echo 
    " <select name=\"artoptid\">";

                  while (
    $opt  mysql_fetch_array ($getopt)) {

                   echo 
    "<option value=\"$opt[id]\"> $opt[artopt] - ".ShopWaehrungFormat($opt[artpreis])."</option>";

                  }

                  echo 
    "</select>";

              }
    "; 
    lg


    chris

  • #2
    http://www.php-resource.de/forum/sho...ghlight=%24sel
    INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


    Comment


    • #3
      oder auch http://dclp-faq.de/q/q-formular-select.html
      I don't believe in rebirth. Actually, I never did in my whole lives.

      Comment

      Working...
      X