Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $mysqli = new mysqli("localhost", "root", "", "work_fb02");
- /* check connection */
- if (mysqli_connect_errno()) {
- printf("Connect failed: %s\n", mysqli_connect_error());
- exit();
- }
- @isset($_GET['act'])?$act=$_GET['act']:"";
- if(isset($act)&&$act=='tiket')
- {
- $res=array();
- $id=$_GET['id'];
- $sql="select count(*) c from bus_tiket where bus=$id and status=1";
- $q=$mysqli->query($sql);
- if(!$q)
- {
- die($mysqli->error.$sql);
- }
- $r=$q->fetch_assoc();
- $res['total']=$r['c'];
- $sql="select * from bus_tiket where bus=$id and status=1";
- $q=$mysqli->query($sql);
- $a=array();
- if(!$q)
- {
- die($mysqli->error);
- }
- while($r = $q->fetch_assoc())
- {
- $r['link']="<a >Lihat</a>";
- $r['tanggal']=date("d-m-Y",strtotime($r['tanggal']));
- $a[]=$r;
- }
- $res['rows']=$a;
- $json=json_encode($res);
- die($json);
- }
- //===================
- if(isset($act)&&$act=='bus')
- {
- $res=array();
- $sql="select count(*) c from bus";
- $q=$mysqli->query($sql);
- if(!$q)
- {
- die($mysqli->error.$sql);
- }
- $r=$q->fetch_assoc();
- $res['total']=$r['c'];
- $sql="select * from bus ";
- $q=$mysqli->query($sql);
- $a=array();
- if(!$q)
- {
- die($mysqli->error);
- }
- while($r = $q->fetch_assoc())
- {
- $r['link']="<a href='?bus=$r[id]'>Lihat</a>";
- $a[]=$r;
- }
- $res['rows']=$a;
- $json=json_encode($res);
- die($json);
- }
- ?>
- <link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/css/main.css">
- <link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/metro-green/easyui.css">
- <link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/icon.css">
- <link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/demo/demo.css">
- <script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery-1.8.0.min.js"></script>
- <script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
- <?php
- if(isset($_GET['bus']))
- {
- ?><div style='text-align:left;padding:10px 15px'><a href="?1">back</a></div>
- <table class="easyui-datagrid" title="BUS" style="width:700px;height:250px"
- data-options="singleSelect:true,collapsible:true,
- url:'?act=tiket&id=<?=$_GET['bus'];?>',method:'get'">
- <thead>
- <tr>
- <th data-options="field:'tanggal',width:150">Tanggal Berangkat</th>
- <th data-options="field:'nama',width:90,align:'center'">Nama</th>
- </tr>
- </thead>
- </table>
- <?
- }else{
- ?>
- <table class="easyui-datagrid" title="BUS" style="width:700px;height:250px"
- data-options="singleSelect:true,collapsible:true,url:'?act=bus',method:'get'">
- <thead>
- <tr>
- <th data-options="field:'bus',width:80">BUS</th>
- <th data-options="field:'link',width:60,align:'center'"> </th>
- </tr>
- </thead>
- </table>
- <?
- }
- /*
- CREATE TABLE IF NOT EXISTS `bus` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `bus` varchar(50) NOT NULL,
- PRIMARY KEY (`id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
- INSERT INTO `bus` (`id`, `bus`) VALUES
- (1, 'bus1'),
- (2, 'bus2');
- CREATE TABLE IF NOT EXISTS `bus_tiket` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `bus` int(11) NOT NULL,
- `tanggal` date NOT NULL,
- `nama` varchar(50) NOT NULL,
- `input` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
- `status` int(11) NOT NULL DEFAULT '1',
- PRIMARY KEY (`id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;
- INSERT INTO `bus_tiket` (`id`, `bus`, `tanggal`, `nama`, `input`, `status`) VALUES
- (1, 1, '2013-10-12', 'Nama1', '2013-10-12 15:13:13', 0),
- (2, 1, '2013-10-12', 'Nama2', '2013-10-12 15:13:13', 1),
- (3, 1, '2013-10-12', 'Nama3', '2013-10-12 15:13:13', 1),
- (4, 1, '2013-10-14', 'Nama4', '2013-10-12 15:13:13', 1),
- (5, 1, '2013-10-12', 'Nama5', '2013-10-12 15:13:13', 1);
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement