Monday, May 9, 2011

To add Two number by useing classes in php

<?php
class abc
{
   
   
 function addition ($a=0,$b=0)
 {
    
   
    return ($a + $b);  
 }

 
 
 
 function multi ($a=1, $b=1)
 {
   

  
    return ($a * $b);  
 }



 function div($a=1 , $b=1 )
 {
  
    return ($a / $b);
 }

 }

$a=new abc;
//echo $a->addition($value1 + $value2);
?>

<html>

<body>
<form method="post">
<input type="text" name="value1" value="0" />
<input type="text" name="value2" value="0" />
<input type="submit" name="submit" value="Sum" /><br />
addtion<input type="text" value="<?php echo $a->addition($_POST['value1'] + $_POST['value2']) ?>" /><br />
multiplication<input type="text" value="<?php echo $a->multi($_POST['value1'] * $_POST['value2']) ?>" /><br />
Division<input type="text" value="<?php echo $a->multi($_POST['value1']/$_POST['value2']) ?>" /><br/>
</form>
</body>
</html>

how to make config file

 http://www.hotscripts.com/category/php/

<?php  $dbHost = 'localhost';
    $dbUser = 'root';
    $dbPass = '';
    $dbName = 'vedemo1';
    $con = mysql_connect($dbHost, $dbUser, $dbPass, $dbName);
    mysql_select_db("vedemo1",$con);  
?>

Sunday, May 8, 2011

How to make a custom Simple module to show your static data in Drupal



Drupal is totally based  on module   I am also  studying module and trying to implement module .
 Here  I am describing the  custom module how to show your  data by module .
 For this you first have to make the  the  file  for module  info  .  I  am  making  it  by my name   vikas.info 

And put your module information on it by the following format

;$Id$
name = "Vikas  module"
description = "this is fist vikas fisrst module"
core = 6.x
php = 5.1

Remember  always  save your custom  module in  site/all/module/

After making  vikas.info  file  save it on above location in folder vikas
Now you have to  make  file for the module  data  now  name the new file
As  vikas.module   and put the following data  in it

<?php
// $Id$
/**
 * @file
 * Module for fetching data from Goodreads.com.
 * This module provides block content retrieved from a
 * Goodreads.com bookshelf.
 * @see http://www.goodreads.com
 */
 /**
 * Implementation of hook_block()
 */
function vikas_block($op='list', $delta=0, $edit=array()) {
  switch ($op) {
    case 'list':
      $blocks[0]['info'] = t('Goodreads Bookshelf');
      return $blocks;
    case 'view':
      $blocks['subject'] = t('vikas');
      $blocks['content'] = t('hello  world ');
      return $blocks;
  }
}
Now   you  static module  I studied it from book and  for good read so not  changing the info
 Now go to your drupal admin  panel   and activate the module and from the block select the option for the  block where you want to display   .this module is compatible with drupal 6.x version

How To make a Widget in word press




Hello friend  you can  easily make a simple widget   by the given format
 You  have only to give  you condition  query for the particular data to display from  your data base  or  you can easily set it in your wp side bar by dra and drop .

Code given below is

<?php
/*
Plugin Name: Per Page Post
Plugin URI: http://dhanjalsolution.com/
Description: per page Post widget
Author: Vikas Gautam
Version: 2
Author URI: http://dhanjalsolution.com/
*/

function sampleeventcategory()
{
   $page_name="index.php"; //  If you use this code with a different page ( or file ) name then change this
                                                                $start=$_GET['start'];
                                                                if(strlen($start) > 0 and !is_numeric($start)){
                                                                echo "Data Error";
                                                                exit;
                                                                }
                                                                $eu = ($start - 0);
                                                                $limit = 2;                                 // No of records to be shown per page.
                                                                $this1 = $eu + $limit;
                                                                $back = $eu - $limit;
                                                                $next = $eu + $limit;
                               
         $pname = $_REQUEST['event'];
   

/// here  you have to give your query and   show your date   or call data from data base



And after that you have to put the  code  

function widget_myeventcategory($args) {
  extract($args);

  $options = get_option("widget_myeventcategory");
  if (!is_array( $options ))
{
$options = array(
      'title' => 'My Widget Title'
      );
  }

  echo $before_widget;
    echo $before_title;
      echo $options['title'];
    echo $after_title;

    //Our Widget Content
    sampleeventcategory();
  echo $after_widget;
}

function myeventcategory_control()
{
  $options = get_option("widget_myeventcategory");
  if (!is_array( $options ))
{
$options = array(
      'title' => 'My Widget Title'
      );
  }

  if ($_POST['myeventcategory-Submit'])
  {
    $options['title'] = htmlspecialchars($_POST['myeventcategory-WidgetTitle']);
    update_option("widget_myeventcategory", $options);
  }

?>

  <p>
    <label for="myeventcategory-WidgetTitle">Widget Title: </label>
    <input type="text" id="myeventcategory-WidgetTitle" name="myeventcategory-WidgetTitle" value="<?php echo $options['title'];?>" />
    <input type="hidden" id="myeventcategory-Submit" name="myeventcategory-Submit" value="1" />
  </p>
<?php
}

function myeventcategory_init()
{
  register_sidebar_widget(__(' per page Post '), 'widget_myeventcategory');
  register_widget_control(   ' per page Post ', 'myeventcategory_control', 300, 200 );
}
add_action("plugins_loaded", "myeventcategory_init");
?>

How To call images in Word press



You can call image in word press by using the  code before the path 
Eg      <img src =”<?php bloginfo('template_directory'); ?>/images/book.png”>
And  you images  will show on particular page where you want to display images.

How to call the Perticular category in different format by using single.php file



<?php } elseif (is_single( array( 661, 1, 513, 668) )){?>  

 <div id="content">
      <div class="innerPage">
       <div class="leftlinks">
         <div class="links_heading"><h2>App Development</h2></div>
          <div class="links">
       <ul>
                <?php //$my_query = new WP_Query('category_name=Products&post_status=publish');?>
             <li><a href="http://www.skyhawk.co/test/?p=661">White Label Website</a>   </li>
<li><a href="http://www.skyhawk.co/test/?p=1">Mercury Server</a>               </li>
    <li>        <a href="http://www.skyhawk.co/test/?p=513">custom development</a>       </li>
     <li><a href="http://www.skyhawk.co/test/?p=668">Airtime packages</a>   </li>
            </div>    </div>
            <div class="right_panel">
         <div class="right_content">
<?php wp_list_bookmarks('category_name=Links&title_li=&category_before=&category_after='); ?>
                                <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
                                                <h2><?php the_title(); ?></h2>                                              
                                <?php the_content(); ?>
<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
                                <?php endwhile; ?>
          </div>
        </div>
</div>
 </div>
    <?php } else {?>
<div id="content">
                <div class="leftPart linksleftpart">
                                                <div class="leftPart linksleftpart">
                                                <?php wp_list_bookmarks('category_name=Links&title_li=&category_before=&category_after='); ?>
                                                </div>  </div>
        <div class="rightPart linksrightpart">
                                                <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
                                                <h1><?php the_title(); ?></h1>
                                                <div class="divider"></div>
                                                <div class=""><?php the_content(); ?></div>
<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>                                                <?php endwhile; ?>        </div></div>