The problem is you are creating multiple with name='SID' and the receiving page will probably only accept the first one. You need to create them as an array instead with []
echo " ";
//----------------------------------^^^^^^
In the receiving page, check the contents with var_dump($_POST['SID']). It will be an array and you can iterate it with a foreach().
I note that you are nesting inside s. That is probably not a good approach ( I don't think it is valid HTML). Instead, store all the SID in an array and loop twice to create your inputs.
$ids = array();
while( $row = mysql_fetch_array($result)) {
// First make an array of ids
$ids[] = $row;
}
Then loop over it twice, to build the select options, and the hidden inputs:
// opened above...
// Inside the tag already opened...
foreach ($ids as $id) {
echo "$id[Sname] ";
}
// Close the
//
// Then later, loop to build the hidden inputs in the array format
foreach ($ids as $id) {
echo " ";
}
On the subject of valid HTML... I also see a stray closing in there. is deprecated, and instead you should be using CSS to define font properties.
Update after comments:
If you want to pass the SID along with the value (Sname) in the then it is easiest to skip the hidden entirely. Instead, pass both values in the attribute, separated by something like a |. In the PHP code that receives it, explode() them back into two values:
// In your original while loop:
// The value consists of both SID and Sname, separated by |
// Now, you have no need for the at all. Remove them.
echo "$row[Sname] ";
// Then in the PHP script which receives the form values, explode() them:
// Both values come from the
list($SID, $Sname) = explode("|", $_POST['Sname']);
// Now your variables $SID and $Sname hold the correct values
// If you need to reuse them, store into `$_SESSION
session_start();
$_SESSION['SID'] = $SID;
$_SESSION['Sname'] = $Sname;
// On other scripts, to read the values
session_start();
echo $_SESSION['SID'];
If you are unfamiliar with how to use $_SESSION, review the manual on basic usage. Long story short, you must call session_start() on each script that accesses $_SESSION, and you must do so before the script produces any output, including whitespace. This is the standard method of sharing data between scripts.