You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$sql = "SELECT count(idSP) FROM sanpham WHERE idCL=$idCL$idLoai$min$max AND AnHien=1 ORDER BY $order";
55
+
if(!$result = $this->db->query($sql)) die("loi ket noi");
56
+
if($result->num_rows < 1) echo$sql;
57
+
$row = $result->fetch_array();
58
+
$totalrows = $row[0];
33
59
60
+
if($current_page < 1) $current_page=1;
61
+
$start = ceil($current_page-1)*$per_page;
62
+
63
+
$sql = "SELECT idCL, idLoai, idSP, TenSP, Gia, urlHinh, SoLanMua FROM sanpham WHERE idCL=$idCL$idLoai$min$max AND AnHien=1 ORDER BY $order limit $start, $per_page";
64
+
if(!$result = $this->db->query($sql)) die("loi ket noi");
65
+
66
+
$data = array();
67
+
while($row = $result->fetch_assoc()){
68
+
$data[] = $row;
69
+
}
70
+
return$data;
71
+
}
72
+
73
+
publicfunctionlaysptheoid($id){
34
74
if($id <= 0) header('location: index.php');
35
75
36
76
$sql = "select * from sanpham where idSP=$id";
@@ -102,47 +142,28 @@ public function layvideo($idSP){
$sql = "SELECT count(idSP) FROM sanpham WHERE idCL=$idCL$idLoai$min$max AND AnHien=1 ORDER BY $order";
150
+
$sql = "SELECT count(idSP) FROM sanpham WHERE TenSP LIKE '%$keyword%'";
128
151
if(!$result = $this->db->query($sql)) die("loi ket noi");
129
-
if($result->num_rows < 1) echo$sql;
130
-
$row = $result->fetch_array();
152
+
$row = $result->fetch_row();
131
153
$totalrows = $row[0];
132
154
133
-
if($current_page < 1) $current_page=1;
134
155
$start = ceil($current_page-1)*$per_page;
135
156
136
-
$sql = "SELECT idCL, idLoai, idSP, TenSP, Gia, urlHinh, SoLanMua FROM sanpham WHERE idCL=$idCL$idLoai$min$max AND AnHien=1 ORDER BY $order limit$start, $per_page";
157
+
$sql = "SELECT idCL, idLoai, idSP, TenSP, Gia, urlHinh, SoLanMua FROM sanpham WHERE TenSP LIKE '%$keyword%' ORDER BY TenSP LIMIT$start, $per_page";
137
158
if(!$result = $this->db->query($sql)) die("loi ket noi");
// VALUES ($idSP, 'teo', '[email protected]', 'test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment ', '2016-05-09')";
337
-
// $this->db->query($sql);
338
-
// }
339
-
// }
340
-
341
-
// public function gia(){
342
-
// $sql = "select idSP from sanpham";
343
-
// $result = $this->db->query($sql);
344
-
//
345
-
// $ids = array();
346
-
// while($row= $result->fetch_row()){
347
-
// $ids[] = $row[0];
348
-
// }
349
-
//
350
-
// foreach($ids as $idSP){
351
-
// $num = rand(5, 200);
352
-
// $gia = $num*100000;
353
-
// $sql = "update sanpham set Gia=$gia where idSP=$idSP";
354
-
// $this->db->query($sql);
355
-
// }
356
-
// }
357
-
358
-
// public function solanxem(){
359
-
// $sql = "select idSP from sanpham";
360
-
// $result = $this->db->query($sql);
361
-
//
362
-
// $ids = array();
363
-
// while($row= $result->fetch_row()){
364
-
// $ids[] = $row[0];
365
-
// }
366
-
//
367
-
// foreach($ids as $idSP){
368
-
// $num = rand(777, 33333);
369
-
// $sql = "update sanpham set SoLanXem=$num where idSP=$idSP";
370
-
// $this->db->query($sql);
371
-
// }
372
-
// }
373
-
374
-
// public function ngay(){
375
-
// $sql = "select idSP from sanpham";
376
-
// $result = $this->db->query($sql);
377
-
//
378
-
// $ids = array();
379
-
// while($row= $result->fetch_row()){
380
-
// $ids[] = $row[0];
381
-
// }
382
-
//
383
-
// foreach($ids as $idSP){
384
-
// $ngay = rand(1388530800, 1464732000);
385
-
// $ngaycapnhat = date('Y-m-d', $ngay);
386
-
// $sql = "update sanpham set NgayCapNhat='$ngaycapnhat' where idSP=$idSP";
0 commit comments