misal kita punya data
1,2,3,4,5,6,7,8,9,10,11,12
kadang kita menemukan kasus ini ketika meng order data
1
10
11
12
2
3
4
5
6
7
8
9
nah solusinya gunakan SQL ABS function
tambahkan
ORDER BY ABS(data_yang diorder) atau pada my sql
kelemahannya ketika terdapat nilai negative akan di convert ke nilai positive oleh fungsi ABS().
cara lain gunakan
ORDER BY CAST(data_yang diorder AS SIGNED) ASC
smoga berguna
Thursday, 28 April 2011
Wednesday, 27 April 2011
Refresh content halaman secara ajax dengan fungsi load
untuk meload atau menambahkan isi dari suatu halaman lain kedalam halaman kita secara ajax dapat digunakan fungsi load pada jquery
misal kita punya 2 halaman a.php dan b.php
kita akan meload/memasukkan isi halaman b.php kedalam a.php secara ajax
save sebagai a.php
[sourcecode language="html"]
<!DOCTYPE html>
<html>
<head>
<style>
body{ font-size: 12px; font-family: Arial; }
</style>
<script src="../jquery-1.4.1.min.js"></script>
</head>
<body>
<b>Successful Response (should be blank):</b>
<div id="success"></div>
<b>Error Response:</b>
<div id="error"></div>
<script>
$("#success").load("http://localhost/jquery/load/not-heire.php", function(response, status, xhr) {
if (status == "error") {
var msg = "Sorry but there was an error: ";
$("#error").html(msg + xhr.status + " " + xhr.statusText);
}
});
</script>
</body>
</html>
[/sourcecode]
save sebagai b.php
[sourcecode language="html"]
<?php
echo "hasil loading";
//echo site_url();
?>
[/sourcecode]
misal kita punya 2 halaman a.php dan b.php
kita akan meload/memasukkan isi halaman b.php kedalam a.php secara ajax
save sebagai a.php
[sourcecode language="html"]
<!DOCTYPE html>
<html>
<head>
<style>
body{ font-size: 12px; font-family: Arial; }
</style>
<script src="../jquery-1.4.1.min.js"></script>
</head>
<body>
<b>Successful Response (should be blank):</b>
<div id="success"></div>
<b>Error Response:</b>
<div id="error"></div>
<script>
$("#success").load("http://localhost/jquery/load/not-heire.php", function(response, status, xhr) {
if (status == "error") {
var msg = "Sorry but there was an error: ";
$("#error").html(msg + xhr.status + " " + xhr.statusText);
}
});
</script>
</body>
</html>
[/sourcecode]
save sebagai b.php
[sourcecode language="html"]
<?php
echo "hasil loading";
//echo site_url();
?>
[/sourcecode]
Subscribe to:
Posts (Atom)