phprockers-logo

How to integrate "xing" share button in your site?

1 comments

Steps:
1.Select The button layout as you want display in your site.
2.Provide the Url for which you are going to display the xing share count.(This is optional)
3.Select the language.
4.Copy the code in the textarea and paste it in your page.
Thats it. The All new Xing share button will be displayed in your site.

How to get the post tags by category name in wordpress?

0 comments
Paste this code wherever you want to get post tags for specific category name in wordpress.

<?php

$cat_name = "Test Cat";
query_posts('category_name='.$cat_name); //give the your category name here.

if (have_posts()) : while (have_posts()) : the_post();
$postTags = get_the_tags();
    if ($postTags) {
        foreach($postTags as $tag) {
            $all_tags[] = $tag -> name;
        }
    }
endwhile; endif;

if(!empty($all_tags)) {
    $unique_tags = array_unique($all_tags); //Removes the duplicates tags in the all_tags_arr array.
    echo '<pre>'.print_r($unique_tags, true).'</pre>';
} else {
    echo "No post tags are available for ".$cat_name." - category";
}

?>

How to get the posts by post tags in wordpress

0 comments
We have easily get the post titles from from the post Id. So We have to try to get the post Id using the post tags.

<?php 
               
global  $wpdb;

$postTags = "Accidents";

//Below query can be used to get the post id using post tags.

$querystr ="SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id = (SELECT term_taxonomy_id FROM wp_term_taxonomy WHERE taxonomy = 'post_tag' AND term_id = (SELECT term_id FROM wp_terms WHERE name ='$postTags '))";

$result= $wpdb->get_results($querystr);
//$result have the post id. Now we easily get the post title or post information using post id.

foreach($result as $postid) {

echo get_the_title($postid->object_id).'<br/>';

}

?>

What is normalization?

0 comments
Normalisation is a set of rules and techniques concerned with below:

    1. Identifying relationships among the attributes.
    2. Combining the attributes to form relations.
    3. Combining the relations to form a database.

Normalised relational database gives several benefits to us:

    1. Elimination of redundant data storage in the database.
    2. Close modeling of real world entities, processes, and their  relationships.
    3. Structuring of data so that the model is flexible.

Strip tags in PHP

0 comments
strip_tags() function will return the string with stripped(removed) HTML and PHP tags.

<?php

$string = '<h2>This is PHP Rokcers blogspot.</h2><!-- Comment --> <a href="http://phprockers.blogspot.com/">phprockers</a>';

echo strip_tags($string);

?>

Output:
=======
This is PHP Rokcers blogspot. phprockers

If we want to allow some specific tags in our string, we have to given that tags as parameters in strip_tags function.

<?php

$string = '<h2>This is PHP Rokcers blogspot.</h2><!-- Comment --> <a href="http://phprockers.blogspot.com/">phprockers</a>';

echo strip_tags($string, '<h2><a>');

?>

Output:
=======
<h2>This is PHP Rokcers blogspot.</h2><a href="http://phprockers.blogspot.com/">phprockers</a>

Dynamic upload the multiple files in php with Javascript validation

1 comments
<?php
    $con = mysql_connection() or (mysql_error();
    mysql_db_select("phprockers", $con) or mysql_error();
?>
<html>
<script type="text/javascript" >
    function add_more() {
        var img = document.getElementById("image").value;
        img=parseInt(img)+1;
        var txt = "<br><input type = file name = images"+img+">";
        document.getElementById("image").value=img;
        document.getElementById("files").innerHTML += txt;
    }


    function validate(){
        var img = document.getElementById("image").value;
        img=parseInt(img);

Multiple File uploads in PHP

0 comments
<?php
    $con = mysql_connection() or(mysql_error();

    mysql_db_select("phprockers", $con) or mysql_error();
?>
<form method="POST" action="" enctype="multipart/form-data">

    Images 1: <input type=file name='images1' ><br>
    Images 2: <input type=file name='images2' ><br>
    Images 3: <input type=file name='images3' ><br>
    <input type="submit" name="submit" value="Submit" />

</form>

Important functions in Wordpres

0 comments
 Wordpress Functions:
================
get_the_excerpt() -  It can be used to get the post excerpt content in the current post.

get_post($post->ID) - It can be used to get the post details about current post. It has title,categoryid, category name, post status etc. Here post->ID is optional.

get_the_post_thumbnail($page->ID,array(150,200),'thumbnail') - It can be used for retrive the thumbnail image for the post.

the_title() - It can be used for retrive the title for current post.

Limitatin in MYSQL

0 comments
Table attribute names are eliminated after 31 characters in the database.

The maximum character of database and table is 122 characters in the mysql.

The maximum number of table in a mysql database is 1792.

The maximum number of database in mysql is 20320.

The maximum number of attributes (that is, columns and indexes) per table is 128 characters.

The maximum number of attributes per key is 32.

The maximum permitted size of one row in table is 8052 bytes.

Get the second highest salary from employee table in mysql

2 comments

We have get the second, third, fourth etc. hightest salary from the employee table very easily in mysql/sql.

Getting max highest salary:
===================

SELECT max(salary) as salary FROM employee;

Getting N th highest salary syntax:
========================

SELECT salary FROM employee as emp WHERE (n-1) = (SELECT count(*) FROM employee as emp2 WHERE emp2.salary > emp.salary)

Getting 2nd maximum salary:
=====================
Above syntax, subsitute n=2, then we have to get second max salary.

SELECT salary FROM employee as emp WHERE (2-1) = (SELECT count(*) FROM employee as emp2 WHERE emp2.salary > emp.salary)