从mysql数据库获取值并将其发布到php页面

从mysql数据库获取值并将其发布到php页面,php,mysql,html,sql,Php,Mysql,Html,Sql,我从数据库中获取一个值并将其发布到另一个页面时遇到了一个小问题,下面是我的代码。在search.php上,用户输入price min和price max,然后在result.php页面上,它从数据库中显示产品的名称和价格以及更多信息的链接。(info.php)这第三个页面将根据result.php上显示的产品Id显示一些附加信息 我试图从结果中隐藏Id_product的值,并将其发布到第三个表单,但没有成功。我收到了一个错误通知:info.php第4行中的未定义索引:Id //////searc

我从数据库中获取一个值并将其发布到另一个页面时遇到了一个小问题,下面是我的代码。在search.php上,用户输入price min和price max,然后在result.php页面上,它从数据库中显示产品的名称和价格以及更多信息的链接。(info.php)这第三个页面将根据result.php上显示的产品Id显示一些附加信息 我试图从结果中隐藏Id_product的值,并将其发布到第三个表单,但没有成功。我收到了一个错误通知:info.php第4行中的未定义索引:Id

//////search.php /////

<form  method="post" action="result.php" > 
<tr> <INPUT type=text size=20 name=pricemin ><BR>  </tr>  
<tr> <INPUT type=text size=20 name=pricemax ><BR>  </tr>
<tr> <input type="submit" class="Nom" id="button" value="Valider" /></tr></form>

///////result.php //////

<?php include 'includes/connection.php';
$pricemin = $_POST['pricemin'];
$pricemax = $_POST['pricemax'];
$query = "SELECT * FROM product where price between '$pricemin' and '$pricemax'";
$result = mysql_query($query);?>
<?php if(mysql_num_rows($result) > 0)
while($products = mysql_fetch_array($result)) {?>   
<?php echo $products['name_product'] ;echo $products['price_product'] ;
echo "<a href='http://localhost/mywebsite/info.php'>More infos</a>"
?>
<form method="post" action="info.php" >
<input type="hidden" name="id" value="<?php echo $products['id_product']; ?>" />
</form><?php } ?>...

///// info.php //////

<?php
include 'includes/connection.php';
$id_product = $_POST['id'];
$query = "SELECT * FROM product where id_product='$id_product'";
$result = mysql_query($query);   ?>
<html><head><title>.. </title></head><body>
<?php 
while($products = mysql_fetch_array($result)) {?>
<h1>Product ID : <?php echo  $products['id_product'] ; ?> </h1>
<h1>Product name : <?php echo  $products['name_product'] ; ?> </h1>
<h1>Product Qt : <?php echo  $products['quantity_product'] ; ?> </h1>
<h1>Product Spec : <?php echo  $products['spec_product'] ; ?> </h1>
<?php } ?></body></html>
///search.php/////


///////result.php////// 产品名称: 产品Qt: 产品规格:
试试这个:

//////search.php /////

<form  method="post" action="result.php" > 
<tr> <INPUT type=text size=20 name=pricemin ><BR>  </tr>  
<tr> <INPUT type=text size=20 name=pricemax ><BR>  </tr>
<tr> <input type="submit" class="Nom" id="button" value="Valider" /></tr></form>

///////result.php //////

<?php include 'includes/connection.php';
$pricemin = $_POST['pricemin '];
$pricemax = $_POST['pricemax '];
$query = "SELECT * FROM product where price between '".$pricemin."' and '".$pricemax."'";
$result = mysql_query($query);

if(mysql_num_rows($result) > 0)
while($products = mysql_fetch_array($result)) {
$id = $products['id_product'];
echo $products['name_product'] ;echo $products['price_product'] ;
echo "<a href='info.php?id=";
echo $id;
echo "'>More infos</a>"
?>

<?php } ?>...

///// info.php //////

<?php
include 'includes/connection.php';
$id_product = $_GET['id'];
$query = "SELECT * FROM bien where id_product= '".$id_product."'";
$result = mysql_query($query);   ?>
<html><head><title>.. </title></head><body>
<?php 
while($products = mysql_fetch_array($result)) {?>
<h1>Product ID : <?php echo  $products['id_product'] ; ?> </h1>
<h1>Product name : <?php echo  $products['name_product'] ; ?> </h1>
<h1>Product Qt : <?php echo  $products['quantity_product'] ; ?> </h1>
<h1>Product Spec : <?php echo  $products['spec_product'] ; ?> </h1>
<?php } ?></body></html>
///search.php/////


///////result.php////// ... /////info.php////// 产品名称: 产品Qt: 产品规格:
这应该将ID传递给info.php


另外,表单只有在您提交按钮时才有效,所以如果您要单击链接,表单将不会提交,除非您使用JS onsubmit函数。

您有什么问题?另外,您是否知道search.php中输入框的名称与result.phpbeside中调用的名称不同?因为我编辑了我的代码,所以我的问题是result.php和info.php之间的问题。如何从数据库中获取id值并将其发布到info.php。因为隐藏的输入没有解决我的问题,我现在正在做答案。你真的应该在这里清理你的代码。请学习什么是意大利面条代码。。因为那是你写的我先生,我的专业与编程无关,但我有一家人要养活(一些意大利面),为了保住我的工作,我必须做这个意大利面代码先生,祝你有愉快的一天!生活并非易事,就像魔术一样,这就是我所寻找的:)非常感谢你,我的朋友。很高兴帮助你。还要学习清理代码。顺便说一句,如果你想将数据传递到另一个页面,当你不需要用户输入任何数据而只需要单击时,使用链接而不是表单。