We help IT Professionals succeed at work.
Get Started

Php form: pass more than one value along with select

Dada44 asked
Last Modified: 2013-12-12
Hi all,

I have the code below, it fills a select element in a form with information from a mysql table.

It will be filled with the name of the products stored in the table products, but I would also like to get in process.php  the id of the selected product

How can I do that?? I've tried with a hidden field but I don't know where to place it. If I put it inside of the select element it breaks.

Thanks in advance!!
echo"<form action='process.php' method='POST' id='process'>
<select name='product_sel' >";
$query= "SELECT * FROM products";
$result = mysql_query($query);
      while ($row = mysql_fetch_assoc($result)) {
      $name = $row['name'];
      $id = $row['p_id'];
      echo $name;
      </option> ";

Open in new window

Watch Question
LAMP Developer
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE