我如何更新/編輯我的行的更新版本。我們可以在那裏輸入要更新的行,而不是使頁面查看所有行並建立到另一個頁面的鏈接。我已經制定了這個。說明我的更新技術和可能的更簡單的方法
<html>
<head>
<meta charset="UTF-8">
<title>Crud Functions - Bookshelf</title>
<link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body>
<div class="header">
<div>
</div>
</div>
<div class="body">
<div>
<div>
<div>
<div class="programs">
<h2>Book Options:</h2>
<div class="first">
<ul>
<li class="selected">
<a href="showbooks">View Books</a>
</li>
<li>
<a href="showinsert">Add Book</a>
</li>
<li>
<a href="showupdate">Update Book</a>
</li>
<li>
<a href="showdelete">Delete Book</a>
</li>
</ul>
</div>
<div>
<?php echo form_open('bookstore/update'); ?>
<table cellpadding='5'>
<th>Update</th>
<th>Book ID</th>
<th>Title</th>
<th>Author</th>
<th>Released Year</th>
<th>ISBN</th>
<?php
if(isset($books)) : foreach($books as $book) :
?>
<tr>
<td><input type="submit" name="idtoupdate" value="<?=$book['book_id']?>"/></td>
<td><?php echo $book['book_id'] ?></td>
<td><input type="text" name="bkname" value="<?php echo $book['book_name'] ?>"/></td>
<td><input type="text" name="bkauthor" value="<?php echo $book['book_author'] ?>"/></td>
<td><input type="text" name="bkyear" value="<?php echo $book['book_year'] ?>"/></td>
<td><input type="text" name="bkisbn" value="<?php echo $book['book_isbn'] ?>"/></td>
</tr>
<?php
endforeach;
?>
<?php
else :
?>
<h5>No records</h5>
<?php
endif;
?>
</table>
<?php echo form_close();?>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
到目前爲止它的工作原理。雖然我不知道我是否可以同時更新多行或需要更多編碼。但生病的嘗試,這是我學習嘗試尋找更好,更快的做事方式的一種方式。
兄弟! :( –
怎麼回事?有什麼不對嗎?你可以指出來,所以我可以練習正確的編碼方式 我看到了,問題是我用文本框,而不是提交按鈕,我用鏈接..雖然我可以只需在鏈接右側放置一個提交按鈕? 或者我可以使用表單。稍後修改它..即時通訊仍然在等待更多的澄清..林總是渴望向專業人士學習:) –
不使用base_url準備鏈接讓CI用你的<?php回聲錨('控制器/函數名/')。 $ param_here,'顯示文字'); ?> – Nishanthan