Jump to content

Hidden input field inside a select?


Mutley

Recommended Posts

I need to get a field from the database and attach it with the loop that is created around the <select> options, however doing a hidden field won't work, as it isn't detected when in a <select>

 

Code:

<?php
	$result = mysql_query("SELECT prod_id FROM loadout WHERE user_id = '$user_id' AND slot = 'car' LIMIT 1");
	while($row = mysql_fetch_array( $result ))
    	{
	$selected = $row['prod_id'];
	}

$sql  = "SELECT prod_id, dam FROM own WHERE user_id = '$user_id' AND market_id = '0' AND slot = 'car'";
$result = mysql_query($sql);
?>
<td><select name="car">
<?
if(mysql_num_rows($result)!=0) { // (1)
while(list($prod_id, $dam_car) = mysql_fetch_row($result)) { // (2)
	$result1 = mysql_query("SELECT name FROM products WHERE prod_id = '$prod_id' LIMIT 1");// (3)
	while($row1 = mysql_fetch_array( $result1 ))
    	{
?>
<option value="<?=$prod_id?>"<? if($selected == $prod_id) { echo " selected"; }else{ echo ""; }?>><?=$row1['name']?></option>
<?
	}	// (3)
}		// (2)
}		// (1)
?>
</select></td>

 

"dam" is the field I want posting but where do I put it? So later on I can do an update query but I need that field associated with the selected option from the drop down (same DB row).

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/44250-hidden-input-field-inside-a-select/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.