将while值传递给另一个表单

时间:2017-07-30 09:12:44

标签: php

在下面的代码中,我能够从数据库中获取值。现在,检索到的值需要传递给另一个表单。

PHP:

<?php
  require('administrator/connect-db.php');
    $www_root = 'http://localhost/secure/cem/administrator/profile/';
  $qry = mysql_query("SELECT * from dealer_package_details");
  if(!$qry){echo mysql_error();}else{
      while($row = mysql_fetch_array($qry)){
        echo "<div class='col-sm-4 sm-margin-b-50'>";
        echo "<form action='test.php'>";
        echo "<div class='margin-b-20'>";
        echo "<div class='wow zoomIn' data-wow-duration='.3' data-wow-delay='.1s'>";
        echo '<img class="img-responsive" name="pport" src="', $www_root, '/', $row['pport'], '" alt="', $row['pport'], '"/>';
        echo "</div>";
        echo "</div>";
        echo "<h3><a href='#' name='name_of_the_product'>" . $row['package_id'].$row['name_of_the_product']."</a></h3>";
        echo "<input type='submit' name='submit' value='book now'>";
        echo "</div>";

    }
  }
?>

以下代码描述了需要传递值的第二种形式。

HTML:

<form method="POST" action="insrt.php">
<input name="name_of_the_product" type="text" class="form-control name_of_the_product"  value="<?php echo $_POST["name_of_the_product"]; ?>" readonly/>
<input name="package_id" type="text" class="form-control package_id"  value="<?php echo $_POST["package_id"]; ?>" readonly/>
<input type="submit" name="submit" value="Save">

1 个答案:

答案 0 :(得分:0)

我建议隐藏input

PHP:

...
echo "<input type='hidden' name='description' value='".$row['description]."' />";
...

<强> HTML:

...
<input name="description" type="text" value="<?php echo $_POST['description']; ?>">
...