loop problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • raul76@gmx.de

    loop problem

    Hi,
    what is wrong with this part of code?
    I wish to get all values from mysql_query, but don't get the first
    element, the last one empty...
    [the query $raeume works properly]
    echo "<select name=\"raum\"> ";
    while ($zimmer = mysql_fetch_arr ay($raeume))
    {
    $z = printf ($zimmer["zimmerID"]);
    if ($first = false)
    {
    echo "<option name=raum type = text selected value=\"$z\">$z \n";
    $first = true ;
    }
    echo "<option name = raum type = text vale = \"$z\">$z\n" ;
    }

    TIA
    Greetings
  • Tom Thackrey

    #2
    Re: loop problem


    On 11-Oct-2003, raul76@gmx.de (raul76@gmx.de) wrote:
    [color=blue]
    > what is wrong with this part of code?
    > I wish to get all values from mysql_query, but don't get the first
    > element, the last one empty...
    > [the query $raeume works properly]
    > echo "<select name=\"raum\"> ";
    > while ($zimmer = mysql_fetch_arr ay($raeume))
    > {
    > $z = printf ($zimmer["zimmerID"]);
    > if ($first = false)
    > {
    > echo "<option name=raum type = text selected value=\"$z\">$z \n";
    > $first = true ;
    > }
    > echo "<option name = raum type = text vale = \"$z\">$z\n" ;
    > }[/color]

    You probably want if ($first == false) and an 'else' before the last echo.

    --
    Tom Thackrey

    tom (at) creative (dash) light (dot) com
    do NOT send email to jamesbutler@wil lglen.net (it's reserved for spammers)

    Comment

    • warstar

      #3
      Re: loop problem

      maybe this works:

      echo "<select name=\"raum\"> ";
      while ($zimmer = mysql_fetch_arr ay($raeume))
      {
      if ($first = false)
      {
      echo "<option name=raum type = text selected
      value='".$zimme r["zimmerID"]."'>'".$zimm er["zimmerID"]."\n";
      $first = true ;
      }
      echo "<option name = raum type = text vale =
      ''".$zimmer["zimmerID"]."'>'".$zimm er["zimmerID"]."\n";
      }

      I haven't tested this in any way but maybe u get lucky



      On 11 Oct 2003 21:57:55 -0700, raul76@gmx.de (raul76@gmx.de) wrote:
      [color=blue]
      >Hi,
      >what is wrong with this part of code?
      >I wish to get all values from mysql_query, but don't get the first
      >element, the last one empty...
      >[the query $raeume works properly]
      >echo "<select name=\"raum\"> ";
      >while ($zimmer = mysql_fetch_arr ay($raeume))
      >{
      > $z = printf ($zimmer["zimmerID"]);
      > if ($first = false)
      > {
      > echo "<option name=raum type = text selected value=\"$z\">$z \n";
      > $first = true ;
      > }
      > echo "<option name = raum type = text vale = \"$z\">$z\n" ;
      >}
      >
      >TIA
      >Greetings[/color]

      Comment

      Working...