我想在提交後保留文本輸入,但如果我還沒有輸入文本,此代碼將出現在文本框中。我想在提交後保留文本輸入
<br /><font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'><tr><th align='left' bgcolor='#f57900' colspan=
下面的代碼:
<form method="GET" action="display.php">
Search: <input type="text" name="search_box" value= "<?php echo htmlspecialchars($_GET['search_box']); ?>" />
<input type="hidden" name="form" value="1" />
<input type="submit" name="search" value="Search">
</form>
<form method="GET" action="display.php">
<input type="hidden" name="form" value="2" />
<input type="submit" name="delete" value="Delete">
</form>
$submit = isset($_GET['search_box']) ? $_GET['search_box']: '';
$data ="SELECT * FROM students WHERE student_id LIKE '%$submit%'";
$deleteData = "DELETE FROM students WHERE student_id = '$submit'";
if(isset($_GET['search_box'])){
$value1 = $_GET['search_box'];
}
if(isset($_GET['form'])){
switch ($_GET['form']){
case '1':
if ($studentInfo = $db->query($data)){
if($count = $studentInfo->num_rows){
while($row = $studentInfo->fetch_object()){
echo "<tr><td>" . $row->student_id . "</td><td>" . $row->lastName .
"</td><td>" . $row->firstName . "</td><td>" . $row->middleName .
"</td> </tr>";
}
}
}
break;
case '2';
if ($delete = $db->query($deleteData)){
}
}
}
所以你必須明確地設定值2在你輸入欄 – yantrakaar
所以,你希望你的搜索框有一個默認的「搜索...」文本在裏面,如果某些搜索已被請求的完成,那麼它應該包含搜索到的詞組? – someOne
對不起,先生我無法編輯我的問題。 – NoobStudent