從最近幾天開始漫遊,無法完成如何從主數據庫中單擊查看詳細信息按鈕時從數據庫中檢索特定行的數據。 [s_no is unique]如何從數據庫中檢索特定行的數據
這是我的主頁; view.php
<?php
include('dbconnect.php');
$select=mysql_query("SELECT * FROM forms order by s_no desc");
$i=1;
while($userrow=mysql_fetch_array($select))
{
$s_no=$userrow['s_no'];
$title_pro=$userrow['title_pro'];
$institute=$userrow['institute'];
$email=$userrow['email'];
$contact=$userrow['contact'];
$date=$userrow['date'];
?>
<p align="center"><a href="submit_pro.php">View Paginated</a></p>
<div class="display">
<p> S.No : <span><?php echo $s_no; ?></span>
<p> Title of the proposal: <span><?php echo $title_pro; ?></span>
<a href="delete.php?id=<?php echo $s_no; ?>"
onclick="return confirm('Are you sure you wish to delete this
Record?');">
<span class="delete" title="Delete"> X </span></a>
</p>
<br />
<p> Institute: <span><?php echo $institute; ?></span>
<a href="table_print.php?id=<?php echo $s_no; ?>"><span class="edit"
title="Edit"> VIEW DETAIL</span></a>
</p>
<br />
<p> Email: <span><?php echo $email; ?></span>
</p>
<br />
<p> Contact name and address: <span><?php echo $contact; ?></span>
</p>
<br />
<p> SUBMITTED ON : <span><?php echo $date; ?></span>
</p>
<br />
</div>
<?php } ?>
這主要頁面(view.php)工作正常。現在。一旦我點擊view.php(主頁面)上的視圖細節按鈕,它應該查看特定行的所有細節。 下面是table_print(詳細頁面)的代碼,這是不完整的,我不能這樣做。
<?php
$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password ="";
$mysql_database = "iaoform_db";
// Create connection
$conn = new mysqli($mysql_hostname, $mysql_user, $mysql_password, $mysql_database);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$id = $_GET['id']; //read id from get inputs
$sqli = "SELECT s_no, title_pro, type, cycle, type_pro, thesis, year,
proposer, institute,
email,present,contact,abstract,status_ongoing,status_file,
sch_request,no_night,no_night_impossible,just_request,mode_ob,
brief_descrip,plan,hfosc_b,hfosc_n,hfosc_g,hfosc_s,hesp_r,hesp_o,
tirspec_b,tirspec_n,tirspec_s,tirspec_c,tirspec_slits,obj_name,obj_ra,
obj_dec,obj_epoch,obj_mag,obj_size,scient_just,date,
status FROM forms WHERE s_no = ?"; //add a where clause with place
holder
$stmt = $conn->prepare($sqli);
$stmt->bind_param("i", $id); //bind input parameters
$stmt->execute();
$stmt->store_result();
/* Get the number of rows */
$num_of_rows = $stmt->num_rows;
/* Bind the result to $row variable */
$stmt->bind_result($row);
if($num_of_rows < 1){ //exit or send the result if number of rows is less than one
echo "Can't find any record!";
mysqli_close($conn);
exit();
} {
?>
<!---------------------------------------------------->
<?php
while ($stmt->fetch())
{
<table class="tg">
<tr>
<th class="tg-9hbo">S.No</th>
<th class="tg-yw4l" colspan="5"><?php echo $row["s_no"]; ?> </th>
</tr>
<tr>
<td class="tg-9hbo">Title of the proposal:</td>
<td class="tg-yw4l" colspan="5"><?php echo $row["title_pro"]; ?>
</td>
</tr>
<tr>
<td class="tg-9hbo">Type:</td>
<td class="tg-yw4l" colspan="5"><?php echo $row["type"]; ?> </td>
</tr>
|
|
|
|
|
<tr>
<td class="tg-9hbo">Submission date:</td>
<td class="tg-yw4l" colspan="5"><?php echo $row["date"]; ?> </td>
</tr>
</table>
/* free results */
$stmt->free_result();
}
mysqli_close($conn);
?>
table_print.php它會很感激完成這個:
第二頁。提前感謝... !!!
@N Moeini非常感謝你的努力。我得到語法錯誤,意外的'<'錯誤...請再次檢查 – explorer104
固定。再次測試。 –
@ explorer104,你有沒有嘗試過嗎? –