. Rising Code Challenges Skip to main content

Posts

How works ng-hide and ng-show in angular js

Angualrjs is the most popular js framework today. This is widely used in develop Mobile apps by using phonegap.  And also angular js used  in website. AngularJS lets you extend HTML vocabulary for your application. The resulting environment is extraordinarily expressive, readable, and quick to develop. ng-show The ngShow directive shows or hides the given HTML element based on the expression provided to the ngShow attribute. The element is shown or hidden by removing or adding the .ng- hide CSS class onto the element. The .ng-hide CSS class is predefined in AngularJS and sets the display style to none (using an !important flag). For CSP mode please add angular-csp.css to your html file. ng-hide The ngHide directive shows or hides the given HTML element based on the expression provided to the ngHide attribute. The element is shown or hidden by removing or adding the ng-hide CSS class onto the element. The .ng-hide CSS class is predefined in AngularJS and sets the display style to no...

Hide show HTML element by javascript

Hide show any element on a HTML page is vary common thing for websites. For Hide and Show elements Jquery is the most common and reliable framework. But There is some performance issue by jquery, so Javascript is the best solution for Hide and show any element on a web page. Sometimes JQuery isn't necessary; if this is the only thing you need to do on a page, the overhead of loading the library far outweighs the need to write concise JavaScript. It seems that hide() , show() and jquery visibility methods in general are not a good option in terms of performance. Hide an element by id  in Javascript: [code language="js"] document.getElementById("id").style.display = "none"; [/code] Hide an element  by id  in jquery: [code language="js"] $("#id").hide(); [/code] Hide an element by class in javascript : [code language="js"] document.getElementsByClassName("class")[0].style.display = "none"; [/code] Hide el...

How to manage multi level categories in PHP and MySQL

For the websites it is common to manage articles, products and much more thing by categories. And these categories have child categories and these child also have child and so in. So this article will show you that how to manage the Multi-level categories tree in PHP and MySql . First of all we need a Database table to store all categories. CREATE TABLE `tblcategory` ( `id` int(10) NOT NULL auto_increment, `pid` int(10) NOT NULL default '0', `title` varchar(255) NOT NULL, PRIMARY KEY (`id`) ); Multilevel categories tree in database table. Now time to get list of all categories with parent and their child, grand child and so on. There are two way to find all categories. 1. First solution that all knows, Recursion   In Recursion, first get all main parents categories and then start a loop and fetch all subcategories with their parent id's. function showCategories($cat_id = 0, $dashes = ''){ $dashes .= '--'; ...

How to handle duplicate data in MySql

This is very common problem in huge database to handle the duplicate data. Tables or result sets sometimes contain duplicate records. Sometimes, it is allowed but sometimes it is required to stop duplicate records. Sometimes, it is required to identify duplicate records and remove them from the table. This chapter will describe how to prevent duplicate records occurring in a table and how to remove already existing duplicate records. Check Duplicate data in table SELECT `col_name`, COUNT(*) as `record_find` FROM table GROUP BY col_name HAVING `record_find` > 1; Above query result will show the column name and number of time of record find in database table. Delete all duplicate records 1) If you want to keep the row with the lowest id value: DELETE n1 FROM names n1, names n2 WHERE n1.id > n2.id AND n1.name = n2.name 2) If you want to keep the row with the highest id value: DELETE n1 FROM names n1, names n2 WHERE n1.id < n2.id AND n1.name = n2.name I used this method in MySQL...

What is a difference between a method and a function?

The words are not opposed to each other but rather describes two possible aspects of a subroutine. An attempt to define the words follows: Subroutine: A set of instructions that can be used several times in the same program. Function: A subroutine that returns a value. Derived from functions in mathematics. Method: A subroutine that belongs to an object or a class. Could be a function. Method is actually a function used in the context of a class/object. When you create a function outside of a class/object, you can call it a function but when you create a function inside a class, you can call it a method . class foo { public function bar (){ // a method ........ } } function bar (){ // a function not part of an object } So an object can have methods (functions) and properties (variables). Source : Stackoverflow

How to create pagination in PHP and MySQL

To handle the large number of records in database pagination is most important part to view records. This article will teach you how to create pagination in PHP with mysql database results. I have created a pagination class which holds the mysql results and html for generated links. This is very simple and secure to use. Follow these steps to set pagination with your DB results. 1. Download a fresh copy of pagination class from github. 2. Extract the zip and put Pagination folder in your project directory. 3. Include the autoload file in your file require_once __DIR__."/Pagination/autoload.php"; Now the pagination class is fully access in your project. 4. Now first create an object of pagination class and pass the limit for display the no of result on a page. $pagination = new \Pagination\Pagination(10); Here 10 is the limit of per page results. Pagination class has been initialized. 5. To get results from database call `sql()` and put your sql query without limit. $paginati...

Login with facebook in core php

login-with-facebook-php create login with facebook in core php First of all create a new facebook app and get the APP_ID and APP_SECRET_KEY . Now time to install facebook sdk directly or by composer By composer create a file in your directory composer.json { "require" : { "facebook/php-sdk-v4" : "~5.0" } } and run command composer install and facebook phpsdk will download in your directory. Now create a file index.php and configure facebook sdk. Generate login url - Create a call back page/url for handle facebook response login-call_back.php And now you can access user's facebook information. Download source code View Live Demo