RE: [PHP] Combo Box containing field

2001-03-10 Thread Don Read

On 10-Mar-01 RealGM wrote:
> Hi,
> 
> Does anyone know how I can create a combo box in my php file that reads the
> options in from a database field?
> 
> I can create combo boxes fine containing values that I enter, but I want it
> to read the values from the database into the drop down box for the user to
> select.
> 
> Thanks,
> Michael.
> 

function selectoption($k, $v, $comp) {
printf("%s\n", 
  $k, $comp == $k ? "SELECTED" :"", $v);
}

$qry="select id,name)
  from country order by name";
$dbres = @mysql_query($qry);
if ($dbres) {
echo '';
while ( $row = mysql_fetch_object($dbres))  {
selectoption($row->id, $row->name, $usercountry);
}
echo "\n";
}

Regards,
-- 
Don Read [EMAIL PROTECTED]
-- If you are going to sin, sin against God, not the bureaucracy. 
  God will forgive you but the bureaucrats won't. 

-- 
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]




Re: [PHP] Combo Box containing field

2001-03-10 Thread Web Admin

Hi Michael,
Yes I do! Take a look at the code snippet below:

echo "";
$level2 = $db->execute("select typename from types");
   do {
   $value=$level2->fields[0];
   echo "$value";
   $level2->nextRow();
} while (!$level2->EOF);
   $level2->close();
echo "";

Just change the query in the 2nd line of the code to the 
desired query. You'll see the result ;-)
Best of luck,
Ahmad Anvari da Code Guru
  - Original Message - 
  From: RealGM 
  To: [EMAIL PROTECTED] 
  Sent: Saturday, March 10, 2001 4:21 PM
  Subject: [PHP] Combo Box containing field


  Hi,

  Does anyone know how I can create a combo box in my php file that reads the options 
in from a database field?

  I can create combo boxes fine containing values that I enter, but I want it to read 
the values from the database into the drop down box for the user to select.

  Thanks,
  Michael.





[PHP] Combo Box containing field

2001-03-10 Thread RealGM

Hi,

Does anyone know how I can create a combo box in my php file that reads the options in 
from a database field?

I can create combo boxes fine containing values that I enter, but I want it to read 
the values from the database into the drop down box for the user to select.

Thanks,
Michael.