Hi guys, me again.
Having an issue with a multiple select form object that is generated through PHP and retrieves and displays MYSQL values.

it displays and retrieves correctly and PHP produces is correctly, however, the form submission to post the values to MYSQL do not, instead it posts the first item selected only instead of all of them.

Any help is greatly appreciated as this has been annoying me for days!

<form action="addproductpost.php?sel=<?php echo $selectedvalue; ?>" enctype="multipart/form-data" method="post">
      <div class="style3"> <br />
      <table width="568" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr class="style1">
              <td><div align="center" class="style1 style19 style20">Select Functions</div></td>
              <td><div align="center" class="style21"><span class="style11"><span class="style22">Add a Product</span></span></div></td>
            </tr>
            <tr>
              <td width="92"><label>     
                    <?php
					$con = mysql_connect($sqlserver,$sqluser,$sqlpassword);
					if (!$con)
  						{
  							die('Connection to SQL Server failed. Error:   ' . mysql_error());
 						}
						mysql_select_db($sqldb, $con);
						
						$result = mysql_query("SELECT functions FROM functions");
						?>
						<select id="func" name="func" multiple="multiple">
						<?php
						if (mysql_num_rows($result)>0)
						{
								while($row=mysql_fetch_array($result))
							{
							?>
							<option atomicselection="on" value="<?php echo "$row[functions]"; ?>"><?php echo "$row[functions]"; ?></option>";
							<?php
							}
						}
						?>
						</select>
						<?php
						mysql_close($con)
					?>
              </label></td>
              <td width="476"><p align="center"><span class="style1"><strong><strong><strong><strong>Product Name:</strong><strong><br />
                  <input name="productname" type="text" class="style14" style="width: 400px" id="productname" >
                  <span class="style14"> </span></strong><br>
                  <br >
                  Product INCI:</strong></strong><strong><span class="style2"><strong><strong><br >
                  <textarea name="productinci" rows="3" cols="1" wrap="virtual" class="style14" id="productinci" style="width: 400px"></textarea>
                  <br >
                  <br >
                  </strong></strong></span></strong>Product Detailed Description:</strong></span><strong><br class="style14" />
                        <textarea cols="15" name="productdescription" rows="1" class="style14" style="width: 400px; height: 142px" id="productdescription"></textarea>
                  </strong></p>
                <div align="center"><strong></strong></div>
                <strong>
                  <div align="center"></div>
                </strong>
                  <div align="center">
                    <table width="100%" align="center" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="239" class="style5" style="height: 23px"><strong>
                          <label id="Label1"></label>
                        </strong>                          <label><span class="style1">Supplier:</span><br />
                        <?php
					$con = mysql_connect($sqlserver,$sqluser,$sqlpassword);
					if (!$con)
  						{
  							die('Connection to SQL Server failed. Error:   ' . mysql_error());
 						}
						mysql_select_db($sqldb, $con);
						
						$result = mysql_query("SELECT supplier FROM suppliers");
						?>
						<SELECT name="supplist">
						<?php
						if (mysql_num_rows($result)>0)
						{
								while($row=mysql_fetch_array($result))
								
							{
							?>
								<option value="<?php echo "$row[supplier]"; ?>"><?php echo "$row[supplier]"; ?></option>
							<?php 
							}
							
						}
						?>
						</SELECT>
						<?php
						mysql_close($con)
					?>
                        </label></td>
                        <td width="238" class="style5" style="height: 23px"><strong>
                          <input name="Submit" style="width: 125px" type="submit" value="Add product" class="style14" />
                        </strong></td>
                      </tr>
                    </table>
                </div></td>
            </tr>
          </table>
        </div>
    </form>

Here is the second part, the PHP page that posts the data to the MYSQL table:

<?php
require("config.php");
if(isset($_SESSION['username']))
{
}
else
{
header("location:denied.php");
}
?>
<html>
<head>
<style type="text/css">
.style1 {
	font-family: Calibri;
}
body {
	background-color: #006666;
}
.style2 {color: #FFFFFF}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body class="style1">
<?php

$con = mysql_connect($sqlserver,$sqluser,$sqlpassword);
if (!$con)
  {
  die('Connection to SQL Server failed. Error:   ' . mysql_error());
  }

mysql_select_db($sqldb, $con);
$supplier = $_POST[$supplist];
(foreach($_POST['func'] as $funcs))
$functions = "$funcs";

$sql="INSERT INTO products (name, inci, description, functions, supplier)
VALUES('$_POST[productname]','$_POST[productinci]','$_POST[productdescription]','$_POST[func]', '$_POST[supplist]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "Product added successfully, please wait...";

mysql_close($con)
?>

<meta http-equiv="refresh" content="1;url=dashboard.php">
<span class="style2">
 <strong></strong></span>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.