Pramod T P

Search
Skip to content
  • Home
  • PHP
  • WordPress
  • Linux
  • Magento
  • My SQL
  • Profile
  • comments

Monthly Archives: May 2011

Wordpress

Get current category id – WordPress

May 31, 2011 Pramod T P Leave a comment

<?php

function getCurrentCatID(){

global $wp_query;

if(is_category() || is_single()){

$cat_ID = get_query_var(‘cat’);

}

return $cat_ID;

}

echo $getCurrentCatID();

?>

CategoryPHPWordpress
Wordpress

Print the substring of the post content – WordPress

May 29, 2011 Pramod T P Leave a comment

<?php

$content = get_the_content();

echo substr(strip_tags($content), 0, 100);

?>

PHPPostsWordpress
Wordpress

Categories of a post – WordPress

May 29, 2011 Pramod T P Leave a comment

<?php

foreach((get_the_category(POST-ID)) as $category) {

echo  $category->cat_name;

}

?>

CategoryPHPPostsWordpress
Wordpress

Read custom field values of a post – WordPress

May 29, 2011 Pramod T P Leave a comment

The below given code will list all the values added to the given fields

<?php

$custom_fields = get_post_custom(POST_ID);

$fieldsValue = $custom_fields[‘FIELD’];

foreach ( $fieldsValue as $key => $value )

echo  $value . “<br />”;

?>

 

 

CustomWordpress
Javascript

How to check if a Javascript function exists

May 29, 2011 Pramod T P Leave a comment

function myFunction() {

}
if(window.myFunction) {

alert(“‘myFunction’ already exists”);

} else {

alert(“‘myFunction’ does not already exists”);

}

FunctionsJavascript
PHP

List databases – PHP

May 28, 2011 Pramod T P Leave a comment

<?php

mysql_list_dbs();

Example :

$connection=mysql_connect(“localhost”,”root”,”password”);

$dataBases = mysql_list_dbs($connection);

while ($db = mysql_fetch_object($dataBases)) {

echo $db->Database . “<br />”;

}

?>

MySQLPHP
PHP

Get number of affected rows in mysql operation – PHP

May 28, 2011 Pramod T P Leave a comment

<?php

mysql_affected_rows();

?>

 

MySQLPHP
PHP

Check if a class exists – PHP

May 28, 2011 Pramod T P Leave a comment

<?php

if ( class_exists( “class-name” ) ) {

echo “Exists”;

}

?>

 

PHP
My SQL

Close MySQL connection – PHP

May 28, 2011 Pramod T P Leave a comment

<?php

mysql_close();

?>

MySQLPHP
PHP

Select MySQL database – PHP

May 28, 2011 Pramod T P Leave a comment

<?php

mysql_select_db (DB-NAME)

?>

MySQLPHP

Posts navigation

1 2 … 8 Next →

Zend | Magento Certified PHP | eCommerce Architect

For Latest Updates
Visit phpcodez.com

Categories

Recent Posts

  • Regular expression
  • preg_match
  • Redirect root domain to a subdomain .htaccess
  • Redirect root domain to a subfolder .htaccess
  • Force SSL htaccess
May 2011
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
« Apr   Jun »

Recent Comments

togel online's avatartogel online on How to terminate the current s…
business funding's avatarbusiness funding on compare two strings – ja…
unsecured loans uk's avatarunsecured loans uk on Function to add an element int…
treating back pain's avatartreating back pain on Submit HTML form to pop up pag…
Pura Cleanse's avatarPura Cleanse on Add the block "Based on y…
  • RSS - Posts
Blog at WordPress.com.
Pramod T P
Create a free website or blog at WordPress.com.
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Subscribe Subscribed
    • Pramod T P
    • Already have a WordPress.com account? Log in now.
    • Pramod T P
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...