| 
	
 | 
 Posted by "Richard Lynch" on 06/18/71 11:18 
On Wed, June 8, 2005 9:59 pm, kevin@newage-hosting.com said: 
> I hope you can all help me. I want to take the information I get from a 
> query and use it is a form as a dropdown select box. For example I want to 
> pull the colors from a table and list them in a drop down box and then 
> when 
> a user selects a color it will pass the colorID for use in writing to 
> another table. I hope that comes across the way I mean. :-( Anyway, I 
> think 
> I used to use something called wddx with java to do this when I was coding 
> in ColdFusion. 
 
<?php 
  $color = isset($_REQUEST['color']) ? $color : 'white'; 
  $query = "select color from soaps"; 
  $colors = mysql_query($query, $connection) or 
error_log(mysql_error($connection) . " $query"); 
  $kosher = false; 
  echo "<select name=\"color\">\n"; 
  while (list($c) = mysql_fetch_row($colors)){ 
    //Cheap and easy data scrubbing: 
    if ($c == $color) $kosher = true; 
    $selected = $c == $color ? 'SELECTED' : ''; 
    echo "<option $selected>$c</option>\n"; 
  } 
  echo "</select>\n"; 
  //If they didn't pick a valid color, make it white 
  if (!$kosher) $color = 'white'; 
  //Or log their IP 
  //Or raise a Red Alert. 
  //Or Whatever. 
?> 
 
--  
Like Music? 
http://l-i-e.com/artists.htm
 
  
Navigation:
[Reply to this message] 
 |