在PHP中的表单之间传递值

I have a PHP and MySQL search where a user select a area and matching result are shown. Then when user click on any one result I needed to pass the unique id or name to next form. The search part work but I was confused on passing the name or id to next form since there will be multiple results. There is just one form for all the result and it fetches data from DB based on id or name.

Passing variables from a form is most simply done with either the "POST" or "GET" method in your form to the next page.

Form Methods - http://www.w3schools.com/php/php_forms.asp

Example from: https://www.tutorialspoint.com/php/php_get_post.htm

  <form action = "<?php $_PHP_SELF ?>" method = "GET">
     Name: <input type = "text" name = "name" />
     Age: <input type = "text" name = "age" />
     <input type = "submit" />
  </form>

Passing variables using HTTP method GET or POST is a good way.

Using method GET will make your variables appear in your url like:

www.example.com?id=1&name=William

You can do something like this:

<form action="your/uri/here" method="GET">
Id:<input name="id" value="<?php echo empty($_GET['id'])?$_GET['id']:'';?>">
Name:<input name="name" value="<?php echo empty($_GET['name'])?$_GET['name']:'';?>">
<button type="submit">search now</button>
</form>

In your PHP code you should judge whether the id or name is empty, then, just fetch the result from database according to the search variables.