我创建了一个HTML页面,它从用户那里获取输入,我需要获取特定行的信息。
以下是“ProcessDetails.html”
中保存的HTML代码<form action="details.php" method="get"/>
<h3 align="center"><FONT color=#CCFF66>ENTER SAMPLE NAME</h3>
<p align="center">
<input type="text" id="Samplename" name="Sample_name"/>
</p>
<div style="text-align:center">
<button type="submit" value="SEARCH">
<img alt="ok" src=
"http://www.blueprintcss.org/blueprint/plugins/buttons/icons/tick.png" />
SEARCH
</button>
</form>
以下是保存为“details.php”的php脚本
<?php
$userinput = $_GET['Sample_name'];
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "ProcessTrackingSystem";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_errno) {
printf("Connect failed: %s\n", $conn->connect_error);
exit();
}
$result = mysqli_query($conn, "SELECT * FROM ProcessDetails WHERE Sample_name = '$userinput'") or die(mysqli_error($conn));
$row = mysqli_fetch_assoc($result);
while ($row=mysqli_fetch_row($result))
{
printf ("%s (%s)\n",$row[0],$row[1]);
}
#printf ("SO_Number: %s \n",$row["SO_Number"])
#print_r($row);
printf ("SO_ID:->");
printf ($row['SO_ID']);
printf ("<br>\r\n");
printf ("<br>\r\n");
printf ("No of samples:->");
printf ($row['No_of_samples']);
printf ("<br>\r\n");
printf ("<br>\r\n");
printf ("Sample name:->");
printf ($row['Sample_name']);
printf ("<br>\r\n");
printf ("<br>\r\n");
printf ("Client name:->");
printf ($row["Clientname"]);
printf ("<br>\r\n");
printf ("<br>\r\n");
printf ("Institution:->");
printf ($row["Institution"]);
printf ("<br>\r\n");
printf ("<br>\r\n");
printf ("Run number:->");
printf ($row["Runnumber"]);
printf ("<br>\r\n");
printf ("<br>\r\n");
printf ("Obtained reads:->");
printf ($row["Obtainedreads"]);
printf ("<br>\r\n");
printf ("<br>\r\n");
printf ("Rerun Info:->");
printf ($row["RerunInfo"]);
printf ("<br>\r\n");
printf ("<br>\r\n");
printf ("Total reads:->");
printf ($row["Totalreads"]);
printf ("<br>\r\n");
printf ("<br>\r\n");
printf ("Run date:->");
printf ($row["Rundate"]);
printf ("<br>\r\n");
printf ("<br>\r\n");
printf ("Raw data location:->");
printf ($row["Rawdatalocation"]);
printf ("<br>\r\n");
printf ("<br>\r\n");
printf ("Analyst:->");
printf ($row["Analyst"]);
printf ("<br>\r\n");
printf ("<br>\r\n");
printf ("Mentor:->");
printf ($row["Mentor"]);
printf ("<br>\r\n");
printf ("<br>\r\n");
printf ("Analysis start date:->");
printf ($row["Analysisstartdate"]);
printf ("<br>\r\n");
printf ("<br>\r\n");
printf ("Analysis end date->:");
printf ($row["Analysisenddate"]);
printf ("<br>\r\n");
printf ("<br>\r\n");
printf ("Report location->:");
printf ($row["Reportlocation"]);
mysqli_free_result($result);
$conn->close();
?>
我需要基于样本名称行的表格格式的所有这些数据。 现在它没有在新网页中显示任何输出。
请事先帮助我这样做。
答案 0 :(得分:0)
删除此行
$row = mysqli_fetch_assoc($result);
答案 1 :(得分:0)
在您的表单中,尝试使用post
方法将值发布到其他页面
<form action="details.php" id="searchForm" method="post">
尝试使用请求方法而不是像
这样的方法$userinput = $_REQUEST['Sample_name'];