[PHP] Dynamic List Boxes

2002-06-29 Thread Chase

I am *very* new to PHP, so this may seem like a stupid question...  I am 
trying to generate dynamic drop-down lists for use in an HTML form, but 
I have done something wrong with my code.  Instead of getting one list 
box with three options, I am getting three list boxes with one option. 
I have included this piece of my code...  Can anyone help???


?
$link = mysql_connect(localhost, user, pass);
mysql_select_db(my_db, $link);

$result = mysql_query(SELECT SKU, Description, Retail FROM linecard 
WHERE sku=61 or sku=239 or sku=318, $link);
$num_rows = mysql_num_rows($result);

if($num_rows) {
while($row = mysql_fetch_row($result))

{
   print(select name=\test\);
   print(option value=\$row[0]-$row[1]-$row[2]\$row[1] - 
\$$row[2]/optionbr);
   print(/select);

}

  } else {
print(option value=\\No Parts Created Yet/option);
  }
?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Dynamic List Boxes

2002-06-29 Thread Stuart Dallas

On Saturday, June 29, 2002 at 10:03:16 PM, Chase wrote:
 I am *very* new to PHP, so this may seem like a stupid question...  I am
 trying to generate dynamic drop-down lists for use in an HTML form, but 
 I have done something wrong with my code.  Instead of getting one list 
 box with three options, I am getting three list boxes with one option. 
 I have included this piece of my code...  Can anyone help???

Yes, you have the select open and close tags inside the loop. Move them either
side as follows...

?
$link = mysql_connect(localhost, user, pass);
mysql_select_db(my_db, $link);

$result = mysql_query(SELECT SKU, Description, Retail FROM linecard
WHERE sku=61 or sku=239 or sku=318, $link);
$num_rows = mysql_num_rows($result);

if($num_rows) {
print(select name=\test\);
while($row = mysql_fetch_row($result))

{
   print(option value=\$row[0]-$row[1]-$row[2]\$row[1] -
\$$row[2]/optionbr);

}
print(/select);

  } else {
print(option value=\\No Parts Created Yet/option);
  }
?

-- 
Stuart


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Dynamic List Boxes

2002-06-29 Thread Chase

Thank you Stuart!!  I feel like an idiot...  I had tried moving one or 
the other outside the loop, but not both...  Thank you again!!

Chase

Stuart Dallas wrote:

 On Saturday, June 29, 2002 at 10:03:16 PM, Chase wrote:
 
I am *very* new to PHP, so this may seem like a stupid question...  I am
trying to generate dynamic drop-down lists for use in an HTML form, but 
I have done something wrong with my code.  Instead of getting one list 
box with three options, I am getting three list boxes with one option. 
I have included this piece of my code...  Can anyone help???

 
 Yes, you have the select open and close tags inside the loop. Move them either
 side as follows...
 
 ?
 $link = mysql_connect(localhost, user, pass);
 mysql_select_db(my_db, $link);
 
 $result = mysql_query(SELECT SKU, Description, Retail FROM linecard
 WHERE sku=61 or sku=239 or sku=318, $link);
 $num_rows = mysql_num_rows($result);
 
 if($num_rows) {
 print(select name=\test\);
 while($row = mysql_fetch_row($result))
 
 {
print(option value=\$row[0]-$row[1]-$row[2]\$row[1] -
 \$$row[2]/optionbr);
 
 }
 print(/select);
 
   } else {
 print(option value=\\No Parts Created Yet/option);
   }
 ?
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php