我有问题 如何在数据表中创建,读取,更新,删除(CRUD)操作时刷新表
Screnshot Tables:http://prntscr.com/3voq2l
标头代码/主管代码
<style type="text/css" title="currentStyle">
@import "../stylesheets/demo_table_jui.css";
@import "../stylesheets/ui-lightness/jquery-ui-1.8.4.custom.css";
</style>
<script type="text/javascript" language="javascript" src="assets/js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="assets/js/jquery.dataTables.js"></script>
<script type="text/javascript">
var rw = jQuery.noConflict();
rw(function() {
rw('#ff').form({
success:function(data){
rw.messager.alert('Info', data, 'info');
}
});
});
</script>
正文代码
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database, $koneksi);
$query_rs_datatables = "SELECT * FROM galeri";
$rs_datatables = mysql_query($query_rs_datatables, $koneksi) or die(mysql_error());
$row_rs_datatables = mysql_fetch_assoc($rs_datatables);
$totalRows_rs_datatables = mysql_num_rows($rs_datatables);
?>
表格代码
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
<thead>
<tr>
<th><center>Title</center></th>
<th><center>Date</center></th>
<th><center>Link Video</center></th>
<th><center>Link Photo</center></th>
<th><center>Image</center></th>
<th><center>Action</center></th>
</tr>
</thead>
<tbody>
<?php do { ?>
<tr>
<td><center><?php echo $row_rs_datatables['judul']; ?></center></td>
<td width="120px"><center><?php echo tgl($row_rs_datatables['tgl']); ?></center></td>
<td align="center">
<?php if ($row_rs_datatables['video']!=NULL){?>
<ul class="inline-popups">
<p align="center"><a href="#youtube-popup-<?php echo $row_rs_datatables['id']; ?>" data-effect="mfp-zoom-in">LINK</a></p>
</ul>
<!-- Youtube popup -->
<div id="youtube-popup-<?php echo $row_rs_datatables['id']; ?>" class="video-popup mfp-with-anim mfp-hide">
<div class="video-wrapper">
<iframe src="http://www.youtube.com/embed/<?php echo $row_rs_datatables['video']; ?>" allowfullscreen></iframe>
</div><!-- /.video-wrapper -->
</div>
<?php } else { ?>
<p align="center">-</p>
<?php }?>
</td>
<td align="left">
<?php if ($row_rs_datatables['linkfoto']!=NULL){?>
<div class="magnific-popup-wrap">
<div class="col-xs-6 col-md-3">
<p align="center"><a class="zooming" href="<?php echo $row_rs_datatables['linkfoto']; ?>" title="<?php echo $row_rs_datatables['judul']; ?>">LINK</a></p>
</div>
</div>
<?php } else { ?>
<p align="center">-</p>
<?php }?>
</td>
<td align="left">
<?php if ($row_rs_datatables['foto']!=NULL){?>
<div class="magnific-popup-wrap">
<div class="col-xs-6 col-md-3">
<p align="center"><a class="zooming" href="../images/galeri/<?php echo $row_rs_datatables['foto']; ?>" title="<?php echo $row_rs_datatables['judul']; ?>">LINK</a></p>
</div>
</div>
<?php } else { ?>
<p align="center">-</p>
<?php }?>
</td>
<td>
<center>
<ul class="inline-popups">
<a href="#popup-edit-<?php echo $row_rs_datatables['id']; ?>" data-effect="mfp-zoom-in" style="text-decoration:none"><i class="fa fa-wrench" title="Edit"></i></a>
<a href="#popup-delete-<?php echo $row_rs_datatables['id']; ?>" style="text-decoration:none"><i class="fa fa-trash-o" title="Delete"></i></a></ul>
</center>
<!-- Form popup Edit -->
<div id="popup-edit-<?php echo $row_rs_datatables['id']; ?>" class="white-popup mfp-with-anim mfp-hide">
<form action="" method="POST" >
<CENTER>EDIT GALLERY</CENTER><br/>
<div class="form-group">
<label for="exampleInputEmail1">Title Gallery</label>
<input type="text" maxlength="50" class="form-control" id="addgallery" name="ti" value="<?php echo $row_rs_datatables['judul']; ?>" placeholder="Title Gallery">
</div>
<div class="form-group">
<label>Date</label>
<input type="text" name="dt" class="form-control" value="<?php echo $row_rs_datatables['tgl']; ?>" readonly>
</div><!-- /.form-group -->
<center><label for="exampleInputEmail1">You must choose one of the following</label></center><br/>
<div class="form-group">
<label for="exampleInputEmail1">Unique Link Youtube</label>
<input type="text" value="<?php echo $row_rs_datatables['video']; ?>" class="form-control" id="un" name="yo" placeholder="Eg: HigyM915gw8">
</div>
<div class="form-group">
<label for="exampleInputEmail1">Link Photo</label>
<input type="text" value="<?php echo $row_rs_datatables['linkfoto']; ?>" class="form-control" id="li" name="li" placeholder="Link Photos">
</div>
<div class="form-group">
<label for="exampleInputEmail1">Upload Photo</label>
<div class="input-group">
<span class="input-group-btn">
<span class="btn btn-default btn-file">
<i class="fa fa-camera"></i><input type="file" name="ph" >
</span>
</span>
<input type="text" class="form-control" value="<?php echo $row_rs_datatables['foto']; ?>" readonly>
</div></div>
<center>
<button type="submit" class="btn btn-primary">Submit</button> <button type="reset" class="btn btn-danger">Reset</button>
</center>
</form>
</div>
<!-- Form popup delet -->
<div id="popup-delete-<?php echo $row_rs_datatables['id']; ?>" class="white-popup mfp-with-anim mfp-hide">
<div class="form-group">
<center><label for="exampleInputEmail1">Are You Sure Delete Gallery "<?php echo $row_rs_datatables['judul']; ?>" ?</label></center>
<form action="" method="POST">
</div>
<center><button type="submit" class="btn btn-primary">Yes</button></center> <button type="button" title="Close (Esc)" class="mfp-close">x</button>
</form>
</div>
</center>
</td>
</tr>
<?php } while ($row_rs_datatables = mysql_fetch_assoc($rs_datatables)); ?>
</tbody>
</table>
</div><!-- /.container-fluid -->
<?php
mysql_free_result($rs_datatables);
?>
我没有进行编码删除,创建和更新,我尝试通过phpmyadmin