Do you need a PHP programmer?
Use my services as a freelance PHP programmer by hiring me to do PHP programming on your website project.

I have built many custom PHP applications like project managers, classified ad websites and content management systems. I also work with open source applications such as WordPress, online shopping cart websites like Magento and develop content management systems like Joomla.

Thursday, July 5, 2012

Add element li by using jQuery ( After & Before)

Hello everybody, , :D

Ok, as my title above, today I will share about how to add new element li by using jQuery (after & before). It is possible for you to add new element li with position like you want. So you don't need to make many code for simple task.

This way the code :
## before 

$(".byweb2").before("<li>Added Test before Test 2</li>"); 

## after

$(".byweb2").after("<li>Added Test before Test 2</li>");


You can download the complete code Klik Here
If you have any question, just write your comment below.
I will try to help you as my best :)

Warm regard from Bali Island

Wednesday, June 6, 2012

Replace All Space or X character in Javascript

Hi guys,
Today I will share a little something about Javascript.

It is small thing but I think it is really - really  important, because I have confused about it before :D.
It is about how to remove or replace all of space or x character on your string using Javascript.
I suggest you to use this way, for example :

var bywebs = "1,2,3,4,5,6,7,8,9";
bywebs = bywebs .replace(new RegExp(',', "g"),' '); // it will replace all "," with "(space)"

// result 1 2 3 4 5 6 7 8 9


Ok, this is a simple way, but very helpfull :)
Hope it can helps you.

Warm greeting from Bali

Tuesday, May 29, 2012

Table and Model Name - Cakephp

Hi everyone,

Long time I have no post something.
Today I will write something about "Table and Model Name in Cakephp".
As you know, in Cakephp we should write the name of table in plural.
I mean for example if you want make table with name "user" you should make it like "users" and "post" should be "posts".

So how to handle table names that are written in singular with "...y"?
hehe ... just so simple, I make an example with table name "entry" and it should be "entries". :D

But for Model name in cakephp you should write the name in singular.
you already have a table "entries", than in your app\models , you should make a new file for model. The name of the file is "entry.php" (in singular 'user.php, post.php').
And below is basic code for Model Name :


class Entry extends AppModel {
 var $name = 'Entry';
}

How about if we use underscore in our table names??
for example you have table name "categories_lists", how will we make the Model name?
I show you the simple way,
in your app\models, create a new file with name "categories_list.php".
write this code inside of the file :

class CategoriesList extends AppModel {
 var $name = 'CategoriesList';
}

Ok, that's all
if you have any question, just write your comment below :D
Thanks for your visit.

warm regard from bali :)

Wednesday, April 18, 2012

Auto Request and Manage Json Data

Hello, ,
Today I have got a new knowledge from programming website.
This is about data-interchange format. Did you ever hear about JSON?

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.( you can read more in www.json.org ).

This is example of json data :

{"name":"bywebs.blogspot.com","time":"12 : 20 : 56"}


And now I will make a tutorial to auto request and manage json data every x seconds. But in this tutorial I will use a jquery script (jquery-1.6.1.min.js).

Let's see for my code :

<script type="text/javascript">

    var auto_refresh = setInterval(function(){ // interval auto refresh
 
        $.getJSON("json.php", function(json) { // request method using jquery

                                               // json.php will return json data

            // parsing data

            var table = '';

            table += '<tr><td>Name</td>';

            table += '<td>'+json['name']+'</td></tr>';

            table += '<tr><td>Server Time</td>';

            table += '<td>'+json['time']+'</td></tr>';

            

            //inser data to Id bywebs

            document.getElementById('bywebs').innerHTML = table;


         });

     }, 5000); // will request json every 5 seconds, you can change it

</script>

You can develop this code by yourself.
so for the complete code you can "Download here".

Hope it useful for all, if you have any question and suggestions, just write your comment below. :)

Good Luck.

Monday, April 16, 2012

Replace space and all Illegal character on string - PHP

Hi, ,
Do you search for how to replace/remove illegal character (@#$%^&* etc) in your text string?
On this post I will share you simple code to make it.
This code will only allowed numbers (0-9) and characters (a-z).

my code :

<?php
    $string = 'by^#^we%%&bs.b_((logs+)&#@pot.()*)(~co!~@#_+m';
    $string = preg_replace('/[^0-9 a-z]+/i', '', $string);
    
    echo $string;
?>

And below is code for replace multiple space on your text string

<?php
    $string = 'by   webs.   blog  spot.  com';
    $string = str_replace(array(' '),array(''),$string);
    
    echo $string;
?>

Hope it will useful for all,
If you have questions or suggestions, please write your comment below.

Good Luck :)