Postingan lainnya
Buku Ini Koding!
Baru!
Buku ini akan jadi teman perjalanan kamu belajar sampai dapat kerjaan di dunia programming!
PHP CRUD NEWBIE
ass.. saya newbie diphp..saya mw bertanya?sebenarnya penyebab gagal update dicrud itu apa ya gan?
<?php
include "../../../../conf/connection.php";
$opsi = $_GET['opsi'];
if($opsi == "input"){
$news_title = $_POST['news_title'];
$news_post_by = $_POST['news_post_by'];
$news_content = $_POST['news_content'];
$news_post_date = $_POST['news_post_date'];
$db->query("insert into tb_news(news_title, news_post_by, news_content, news_post_date)
VALUES ('".$news_title."',
'".$news_post_by ."',
'".$db->real_escape_string($news_content)."','".$news_post_date."')");
if($db->error){
echo "gagal mengepost berita";
}
else{ header('location:http://localhost/projectweb/administator/file_data/news/views/form_news.php');}
}
elseif($opsi == "delete"){
$id = $_GET['id'];
$deldata = $db->query("delete from tb_news where id_news='".$id."'");
header('location:../views/list_news.php');
}
elseif($opsi == "update"){
$id = $_POST['id'];
$news_title = $_POST['news_title'];
$news_post_by = $_POST['news_post_by'];
$news_content = $_POST['news_content'];
$news_post_date = $_POST['news_post_date'];
$db->query("update tb_news set news_title ='".$news_title."',
news_post_by ='".$news_post_by."',
news_content ='".$news_content."',
news_post_date ='".$news_post_date."',
where id_news = '".$id."'");
if($db->error){
echo "gagal update berita";
}
else{ header('location:http://localhost/projectweb/administator/file_data/news/views/list_news.php');}
}
?>
<?php
include "../../../../conf/connection.php";
?>
<table>
<tr>
<th>No</th><th>Title</th><th>Posted</th><th>Content</th><th>Date</th><th>#</th>
</tr>
<?php
$q = $db->query("select *from tb_news");
$no=1;
while($r=$q->fetch_array()){
?>
<tr>
<td><?php echo $no; ?></td>
<td><?php echo $r['news_title']; ?></td>
<td><?php echo $r['news_post_by']; ?></td>
<td><?php echo htmlentities(substr($r['news_content'], 0,50)); ?></td>
<td><?php echo $r['news_post_date']; ?></td>
<td>
<a href="edit_news.php?id=<?php echo $r['id_news'];?>">Edit</a>
<a href="../controllers/news_controllers.php?opsi=delete&id=<?php echo $r['id_news']?>">Delete</a>
</td>
</tr>
<?php
$no++;
}
?>
</table>
<?php
include "../../../../conf/connection.php";
$q = $db->query("select * from tb_news where id_news='".$_GET['id']."'");
$r = $q->fetch_object();
$news_title = $r->news_title;
$news_post_by = $r->news_post_by;
$news_post_date = $r->news_post_date;
$news_content = $r->news_content;
?>
<form method="POST" action="../controllers/news_controllers.php?opsi=update" enctype="multipart/form_data">
<input type="hidden" name="id" value="<?php echo $r->id_news; ?>">
<table width="500" border="0">
<tr>
<td>Title</td>
<td>:</td>
<td><input type="text" name="news_title" id="news_title" value="<?php echo $news_title;?>"></td>
</tr>
<tr>
<td>Post by</td>
<td>:</td>
<td><input type="text" name="news_post_by" id="news_post_by" value="<?php echo $news_post_by;?>"></td>
</tr>
<tr>
<td>Content</td>
<td>:</td>
<td><textarea name="news_content" id="news_content"><?php echo $news_content;?></textarea></td>
</tr>
<tr>
<td>Date</td>
<td>:</td>
<td><input type="date" name="news_post_date" id="news_post_date" value="<?php echo $news_post_date;?>"></td>
</tr>
<tr>
<td colspan="3"><input type="submit" name="posting" id="posting" value="Posting"></td>
</tr>
</table>
</form>
<script src='http://localhost/projectweb/assets/js/jquery-2.1.1.min.js' type='text/javascript'></script> //sempet eror disini karena setelah localhost ada spasinya.alhamdulillah karna sabarrr allahu akbarrr 4mei 8.23 tp upload tetep gagal
<script src='http://localhost/projectweb/assets/tinymce/js/tinymce/tinymce.min.js'></script>
<!-- <script src='https://cloud.tinymce.com/stable/tinymce.min.js'></script> -->
<script>
$(document).ready(function() {
tinymce.init({
selector:"#news_content",theme: "modern",width: 1000,height: 400,
plugins: [
"advlist autolink link image list charmap print preview hr anchor pagebreak",
"searchplace wordcount visualblocks visualchars insertdatetime media nonbreaking",
"table contextmenu directionality emoticons paste textcolor responsivefilemanager code"
],
toolbar1: "undo redo | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | styleselect",
toolbar2: "| resfonsivefilemanager | link unlink anchor | image media | forecolor backcolor | print preview code",
image_advtab : true,
relative_urls: false,
external_filemanager_path:"/projectweb/filemanager/",
filemanager_title:"Responsive Filemanager",
external_plugins: { "filemanager" : "/projectweb/filemanager/plugins.min.js"}
});
});
</script>
0
2 Jawaban:
dijelaskan gan gagalnya bagaimana? tulisan errornya apa? masalahnya apa?
0