if(!empty($_POST)){ if(!empty($_FILES)){ //–on upload file (image) get details & encoding base64 :Starts– $file_name = $_FILES[‘file’][‘name’]; $file_size= $_FILES[‘file’][‘size’]; $file_tmp= $_FILES[‘file’][‘tmp_name’]; $file_ext = strtolower( end(explode(‘.’,$file_name))); …
Read MorePHP
Convert stdClass object to array
#Convert stdClass object to array foreach ($object as $value){ $array[] = $value->post_id; }
Read MoreWhich Version of Codeigniter I am using?
#Which version of CodeIgniter am I currently using? Ans: Yes, the constant CI_VERSION will give you the current CodeIgniter version number. CodeIgniter 2, it’s defined …
Read MoreWhether we can have a form inside another form?
#Whether we can have a form inside another form? Though you can have several <form> elements in one HTML page, you cannot nest them. We …
Read Moreget last insert id after insert query in codeigniter active record
– get last insert id after insert query in codeigniter active record function add_post($post_data){ $this->db->insert(‘posts’, $post_data); $insert_id = $this->db->insert_id(); return $insert_id; } …
Read Morehow to get last insert id after insert query in codeigniter active record
#how to get last insert id after insert query in codeigniter active record Example: For add data into table, function add_post($post_data){ $this->db->insert(‘posts’, $post_data); …
Read MoreDecode html encoded contents in php
## Html contents decode in php $contents = Original Content with html encoded tags; $contents_decoded = htmlspecialchars_decode($contents, ENT_QUOTES); echo html_entity_decode($contents_decoded);
Read MoreOrder By Rand in Codeigniter
#Order By Rand in Codeigniter function get_random_page() { $this->db->order_by(‘id’, ‘RANDOM’); or $this->db->order_by(‘rand()’); $this->db->limit(1); $query = $this->db->get(‘pages’); return $query->result_array(); } Codeigniter provides the use of ‘RANDOM’ …
Read MoreCheck if input box checked in jQuery
## Check if the checkbox is checked or not. Here, checkbox is the id of checkbox. $(‘#checkbox’).on(‘click’, function(){ if ($(this).is(‘:checked’)== true) { console.log(‘Checked’); } else …
Read MorePreg match in Jquery
CHECK EXPRESSION LIKE:: 11112233-1234 <input type=”text” value=”” name=”preg” id=”preg” placeholder=”11112233-1234″ form-control”> <script type=”text/javascript”> $(‘#preg’).on(‘keyup’, function(){ var dis = $(this); var _preg = “[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][-][0-9][0-9][0-9][0-9]”; if(dis.val().match(/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][-][0-9][0-9][0-9][0-9]/)){ console.log(‘Matched’); …
Read More