[英]how to display image from database using php and mysql in a html page
[英]How to parse the information from mysql database to html page using php
我創建了一個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();
?>
我需要基於“樣品名稱”行的表格格式的所有這些數據。 現在,它不會在新網頁中顯示任何輸出。
預先感謝我的幫助。
刪除此行
$row = mysqli_fetch_assoc($result);
在您的表單中嘗試使用post
方法將值發布到其他頁面
<form action="details.php" id="searchForm" method="post">
嘗試使用請求方法代替類似的get方法
$userinput = $_REQUEST['Sample_name'];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.