Jump to content

Multi Select List box not passing values


am_25

Recommended Posts

Hi,

  I have a multiselect list box which is being generated dynamically by the DB values.

When I submit the form, I like the selected values of the list box.

But the array returns an empty string.

 

Please help. Here is the code.

I have 2 files

1. empquery.php - where I have the multi select list box and I submit the data

2. empresult.php - Which should get the selected values from $_POST and do the processing.

 

Here is the code for empquery.php

<tr><td>
<form action='empresult.php' method='post'>
<br>Designation:
<?php
$sql2="SELECT distinct(designation) from empdet order by designation asc ";
$result2=mysql_query($sql2);?>
<SELECT  multiple="multiple" name="desi1[]">
<?php
While ($row=mysql_fetch_assoc($result2))
{
$desi=$row['designation'];
  echo "<OPTION  value='$desi'>$desi</OPTION> ";
} ?></select>
&nbsp
<input type='submit' name='submit4' value='submit'></form>
</form></td></tr>

 

empresult.php file

elseif (isset($_POST['submit4']))
  {
   $dg=$_POST['desi1'];
   $n=count($dg);
   $sql="SELECT * from empdet where empid = '$empid'";
   $result=mysql_query($sql);
     While ($rows=mysql_fetch_assoc($result))
{?>      
      <tr><td><?php echo "test"; ?> </td>
      <tr><td><?php echo $rows['empid']; ?> </td>
      <td><?php echo $rows['empname']; ?> </td>
      <td><?php echo $rows['doj']; ?></td>
      <td><?php echo $rows['designation'];?></td>
      <td><?php echo $rows['grade'];?></td>
      <td><?php echo $rows['ctc'];?></td></tr>
<?php
}
  }

Link to comment
https://forums.phpfreaks.com/topic/37728-multi-select-list-box-not-passing-values/
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.