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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.