Skip to content

PHPCodez

Search
  • PHP
  • Magento
  • Javascript
  • HTML
  • My SQL
  • Functions
  • WordPress
  • Plugins
  • Joomla
  • Linux
  • jQuery
  • 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

<script language=”javascript” type=”text/javascript”>

function myFunction() {

}
if(window.myFunction) {

alert(“‘myFunction’ already exists”);

} else {

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

}

</script>

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 … 7 Next →

Beginners' Guide

Recent Posts

  • Upstream sent too big header while reading response
  • Navigate to a Folder from Any Location by Typing a Letter – Linux
  • Magento 2 Admin Content Deployment
  • React vs next JS
  • Disable CAPTCHA Magento 2 Admin Login
  • Difference Between composer.json and composer.lock Files
  • Magento 2 Regenerate URL Rewrites Manually For Categories
  • Magento 2 Regenerate URL Rewrites Manually for Products
  • composer self downgrade

Recent Comments

  • beats solo 4 on allow_url_include
  • Hairstyles on php end of line
  • penipu on cgi.force_redirect
  • lumi777 link alternatif on cgi.force_redirect
  • Beauty Fashion on mysqldump create table if not exists

Categories

  • .htaccess (32)
  • Ajax (4)
  • Apache (43)
  • AWS (11)
  • Cookie (4)
  • Database Model (9)
  • Design Pattern (9)
  • Filter (27)
  • General (187)
  • HTML (5)
  • IP.Board (1)
  • Javascript (99)
  • Jetty (3)
  • Joomla (17)
  • jQuery (63)
  • JSON (3)
  • JSP (1)
  • Linux (125)
  • Magento (371)
  • My SQL (74)
  • nginx (4)
  • OOPs (12)
  • Payment Gateway (1)
  • PHP (1,005)
  • Plugins (11)
  • Prototype (1)
  • session (5)
  • Socialengine (1)
  • SQL (69)
  • SVN (17)
  • Uncategorized (11)
  • Vbulletin (11)
  • Wordpress (89)
Proudly powered by WordPress