Jump to content

Echo dropdown selection


webweever

Recommended Posts

I'm trying to do a couple of things using the dropdown list below. I have a table with id, rank, and amount.

 

1. I need to echo the amount that corresponds to the rank selected from the dropdown list.

2. I also need to put the amount value in a variable so I can do some math with it later on.

 

I've got the dropdown pulling the rank values from the db just not sure how to make it do the rest I'm trying to do.

 

Any help would be greatly appreciated

 

 

<?php
db($host,$db_name,$user,$pass);
function db($host,$db_name,$user,$pass)
{
global $link;
$link=mysql_connect ("$host","$user","$pass");
if(!$link){die("Could not connect to MySQL");}
mysql_select_db("$db_name",$link) or die ("could not open db".mysql_error());
}


$sql="SELECT * FROM dlaw";
$result=mysql_query($sql);

$options="";

while ($row=mysql_fetch_array($result)) {

    $rank=$row["rank"];
    $options.="<OPTION VALUE=\"$rank\">".$rank.'</option>';
}
?>
		<SELECT NAME=rank><OPTION VALUE=0>Select Rank<?=$options?></SELECT>

Link to comment
https://forums.phpfreaks.com/topic/231746-echo-dropdown-selection/
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.