正在開發一個在線應用程序,我有一個php搜索腳本,可以從數據庫中獲取所需的信息。我已經設法在腳本中包含一個刪除和更新按鈕,這樣當用戶搜索一個項目時,顯示,但我不知道如何將按鈕綁定到他們的功能。與Php新,所以任何幫助表示讚賞。這裏是我的搜索代碼...如何更新和刪除搜索PHP腳本?
<?php
// Get the search variable from URL
$var = @$_GET['s'] ;
$trimmed = trim($var); //trim whitespace from the stored variable
// rows to return
$limit=15;
// check for an empty string and display a message.
if ($trimmed == "")
{
echo "<p>Please enter a search value...</p>";
exit;
}
// check for a search parameter
if (!isset($var))
{
echo "<p>We dont seem to have a search parameter!</p>";
exit;
}
//connect to database
mysql_connect("localhost","root",""); //(host, username, password)
//specify database **
mysql_select_db("archive_sys") or die("Unable to select database"); //select which database we're using
// Build SQL Query
$query = "select * from tbl_archivingdetails where archiveid like \"%$trimmed%\" or buildingid like \"%$trimmed%\" or branchid like \"%$trimmed%\" or study like \"%$trimmed%\" or batchnumber like \"%$trimmed%\" or quantity like \"%$trimmed%\" or archivedate like \"%$trimmed%\" or archivedby like \"%$trimmed%\" or archiveeemail like \"%$trimmed%\" or archiveephone like \"%$trimmed%\" or expecteddestructiondate like \"%$trimmed%\" or currarchholderproj like \"%$trimmed%\" or currexpretdate like \"%$trimmed%\" or returnedby like \"%$trimmed%\" or status like \"%$trimmed%\"";
$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);
// next determine if s has been passed to script, if not use 0
if (empty($s)) {
$s=0;
}
// get results
$query .= " limit $s,$limit";
$result = mysql_query($query) or die("Couldn't execute query");
// display what the person searched for
echo "<h2>You searched for: "" . $var . ""</h2>";
// begin to show results set
echo "Results: ";
$count = 1 + $s ;
//the begining of a table with a header
echo " <table border=2>";
echo "<tr align=center>";
echo "<th> Check Code </th>";
echo "<th> Archive ID </th>";
echo "<th> Building ID </th>";
echo "<th> Branch ID </th>";
echo "<th> Study </th>";
echo "<th> Batch Number </th>";
echo "<th> Quantity </th>";
echo "<th> Archive Date </th>";
echo "<th> Archived By </th>";
echo "<th> Archivee Email </th>";
echo "<th> Archivee Phone </th>";
echo "<th> Expected Destruction Date </th>";
echo "<th> currArchHolderProj </th>";
echo "<th> Current Exp Return Date </th>";
echo "<th> Returned By </th>";
echo "<th> Status </th>";
//echo "<th> Action </th><tr><td><input type='submit' name='Submit' value='Delete' /> | <input type='submit' name='Submit' value='Update' /> </td></tr>";
echo " </tr>";
// now you can display the results returned
while ($row= mysql_fetch_array($result)) {
$title = $row["archiveid"];
$title1 = $row["buildingid"];
$title2 = $row["branchid"];
$title3 = $row["study"];
$title4 = $row["batchnumber"];
$title5 = $row["quantity"];
$title6 = $row["archivedate"];
$title7 = $row["archivedby"];
$title8 = $row["archiveeemail"];
$title9 = $row["archiveephone"];
$title10= $row["expecteddestructiondate"];
$title11 = $row["currarchholderproj"];
$title12 = $row["currexpretdate"];
$title13 = $row["returnedby"];
$title14 = $row["status"];
echo" <tr>";
echo "<td><input type='checkbox' name='checkbox' value='".$row['archiveid']."' id='checkbox'/> </td> <td>".$title."</td> <td>".$title1."</td><td>".$title2."</td><td>".$title3."</td><td>".$title4."</td><td>".$title5."</td> <td>".$title6."</td><td>".$title7."</td><td>".$title8."</td><td>".$title9."</td><td>".$title10."</td> <td>".$title11."</td><td>".$title12."</td><td>".$title13."</td><td>".$title14."</td>" ;
echo " </tr>";
}
echo "<tr><tr> <td><input type='submit' name='Submit' value='Delete' /></td> | <td><input type='submit' name='Submit' value='Update' /> </td></tr>";
echo " </tr>";
echo " </table>";
//break before paging
echo "<br />";
?>
我的眼睛。它燃燒。 –
抱歉,Kyle,@ Damien感謝您的編輯。 –