"Rodney J. Woodruff" wrote:

> http://www.php.net/manual/en/function.msql-fetch-array.php

    Okay, call me dense.  I can't figure this out.  This is what I'm trying to
do:

    $sql = "select p_id, project from proj where uid=$uid";
    $result = mysql_db_query($database,$sql);

    (the resulting table in mysql is as follows:
      +------+-----------+
      | p_id | project   |
      +------+-----------+
      |    0 | Undefined |
      |    1 | Work      |
      |    2 | Personal  |
      +------+-----------+
      3 rows in set (0.00 sec)

    ...yes, that 'Undefined' IS a valid project, and the p_id's don't
necessarily start at 0 either.)


    I need that result into the following:
    $items = array(0 => "Undefined", 1 => "Work", 2 => "Personal");

    Reason is, I pass that $items variable to the following function:

  function MakeSelect($items, $selected) {
    $str = "";
    while(list($value, $name) = each($items)) {
      $str .= "<option value=\"$value\"" . ($value != $selected ? \
              ">" : " selected>") . "$name\n";
    }
    return $str;
  }

    ...which then creates (assuming the person had 'Work' previously
selected):

    <select name=whatever_i_specify>
    <option value="0">Undefined
    <option value="1" selected>Work
    <option value="2">Personal
    </select>

    How do I create that $items array?

    AMK4

--
W |
  |  I haven't lost my mind; it's backed up on tape somewhere.
  |____________________________________________________________________
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Ashley M. Kirchner <mailto:[EMAIL PROTECTED]>   .   303.442.6410 x130
  SysAdmin / Websmith                           .     800.441.3873 x130
  Photo Craft Laboratories, Inc.             .        eFax 248.671.0909
  http://www.pcraft.com                  .         3550 Arapahoe Ave #6
  .................. .  .  .     .               Boulder, CO 80303, USA



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to