Sunday, May 8, 2011

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>

Tuesday, April 26, 2011

How to find the second heighst record from table


How to find the max price from the given table in sql
SELECT max(price) FROM `productprice`
How to find  the second heist record from table
SELECT `price` FROM `productprice` group by `price` order by `price` desc limit 1,1

Thursday, March 31, 2011

How to make the text box side bar rounded


How to  make  the  text box side bar rounded

If you required that to make the text box side bar rounded  then you can easily  make it by using the css property.
First of all you have to make a simple text box  .
<input type="text" name="site" value="Site Name" style="font-size:24px;"/>
Now you have to make the css property for the text box to make the corner rounded
Thease are as below
.login_fields input[type=text] {width:197px; height:20px;text-shadow: 0px 0px 1px #e4e4e4; border:0px; border-radius: 4px;-moz-border-radius: 6px;-webkit-border-radius: 6px;}

By using this class  when you include the class  in your text field it show the  rounded images .
<div class="login_fields"><input type="text" name="site" value="Site Name" style="font-size:24px;"/>
</div>
 Try it


How to add the  loader  on submit button when submit:

If you want  that when you click on login button then it show the other image of other color and then
 Loader on its side
By using java script property  onclick or by css property you can easily do this. You first have to download the images and name the same name  for images  as given or  can chage accordingly .
<script>
function  visibility()
{
        if(document.images)
    {
         
       
        document.images.loading3.style.visibility = 'visible';
        document.images.loading4.style.visibility='visible';}
       
       }
     </script>

<td><input type="image" src="images/btn_login.png" name="submit"  onclick = "javascript:return validateForm();"/>
            <img src="images/btn_logingrey.png"  border="0" name = "loading1" style = "visibility:hidden;margin-left: 10px;margin-top: -5px;"/></td>
            <td><img src="images/loading3.gif"  border="0" name = "loading2" style = "visibility:hidden;"/></td>

You can also  use this property also  for this 
<input type="image" src="images/btn_go.png" name="submit"style = "visibility:visible; float: left;" onclick="this.style.visibility = 'hidden'; if(document.images){document.images.loading.style.visibility = 'visible';}"/>
<img src="images/loading4.gif" alt="" class="left_flo" name = "loading" style = "visibility:hidden; margin-left:-64px;"/>


Friday, March 4, 2011

Want to Display your Name in heart shape


If you want to display your name in heart shape  then you have to use code of java script given below and an html code
Inception (Two-Disc Edition) [Blu-ray]
First java code  save this file by the name of heart.js
Code is :
function createHeart(sourceId, resultId) {
    objSource = window.document.getElementById(sourceId);
    objResult = window.document.getElementById(resultId);

    if(objSource.value.length == 0) {
        alert("Vikas Gautam Says Enter  Your name in the Text Box!");
        return false;
    }

    string = objSource.value;

    heart = "";
    heart = ". [red][b] \n";
    heart += "_________"               + partString(string, 8)  + "____________" + partString(string, 9)  + "\n";
    heart += "______"                  + partString(string, 14) + "_______"      + partString(string, 16) + "\n";
    heart += "____"                    + partString(string, 19) + "___"          + partString(string, 19) + "\n";
    heart += "___"                     + partString(string, 32) + "_______"      + partString(string, 4)  + "\n";
    heart += "__"                      + partString(string, 32) + "_________"    + partString(string, 4)  + "\n";
    heart += "_"                       + partString(string, 36) + "_______"      + partString(string, 4)  + "\n";
    heart += "_"                       + partString(string, 40) + "______"       + partString(string, 1)  + "\n";
    heart +=                             partString(string, 44) + "__"           + partString(string, 3)  + "\n";
    heart +=                             partString(string, 47) + "_"            + partString(string, 1)  + "\n";
    heart +=                             partString(string, 49)                                           + "\n";
    heart +=                             partString(string, 49)                                           + "\n";
    heart += "_"                       + partString(string, 47)                                           + "\n";
    heart += "__"                      + partString(string, 45)                                           + "\n";
    heart += "____"                    + partString(string, 42)                                           + "\n";
    heart += "______"                  + partString(string, 37)                                           + "\n";
    heart += "_________"               + partString(string, 31)                                           + "\n";
    heart += "____________"            + partString(string, 25)                                           + "\n";
    heart += "______________"          + partString(string, 20)                                           + "\n";
    heart += "_________________"       + partString(string, 13)                                           + "\n";
    heart += "___________________"     + partString(string, 9)                                            + "\n";
    heart += "_____________________"   + partString(string, 6)                                            + "\n";
    heart += "______________________"  + partString(string, 4)                                            + "\n";
    heart += "_______________________" + partString(string, 2)                                            + "\n";
    heart += "create by hack2007.50webs.com";


    objResult.value = heart;
}
function partString(string, num) {
    if(string.length >= num)
        return string.substring(0, num);

    repeat = Math.ceil(num / string.length);

    newString = "";

    for(i = 0; i < repeat; i++)
        newString += string;

    return newString.substring(0, num);
}
HDMI Cable 2M (6 Feet)
After saving this file you need to create  an html file  by which you able to chage your name in heart shape
Name this file as you want   and past this code to this file and save it
<html>
<table align=”center” bgcolor=”green”>
 <tr>
                    <td width="100%" height="74" align="left" valign="top">
      <p style="margin-top: 0; margin-bottom: 0; line-height:150%">
      <font face="Georgia" style="font-size: 11pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      Vikas Gautam  Says Enter   your name </font></p>

      <p style="margin-top: 0; margin-bottom: 0; line-height:150%">
      <font face="Georgia" style="font-size: 11pt">&nbsp;&nbsp;
      <input id="text" name="text" size="20">
                      <input class="button" accesskey="g" onclick="return createHeart('text', 'result');" value=" Heart" type="button"> </font></p>
      <p style="margin-top: 0; margin-bottom: 0; line-height:150%">
      <font face="Georgia" style="font-size: 11pt">
                      <br>
                      <textarea id="result" rows="17" cols="57" onclick="this.focus(); this.select();" readonly="readonly"></textarea>

                                                              <script src="heart.js"></script></font></p>
                    </td>
                  </tr>
                </table>
                </html>
AmazonBasics High Speed HDMI Cable (6.5 Feet / 2.0 Meters) - Supports Ethernet, 3D, and Audio Return [NEW MODEL]
Now you run the html file in html browser  and enter  your name in the text box and click on the  create  heart  button.

Monday, February 14, 2011

Import an .csv file to my sql data base

To import an .csv file todata base of my sql. Youcan easily

import an .csv file to data base by this script


//impot an ,csv file to my sql data base


//Database connection

$con=mysql_connect("localhost","root","");

if(!$con)
{
die('Could not connect: ' . mysql_error());

}
mysql_select_db("artpoly1",$con);



//query on the pree of submit button after selecting file

if(isset($_POST['submit']))
{

$fname = $_FILES['file_name']['name'];


$chk_ext = explode(".",$fname);


if(strtolower($chk_ext[1]) == "csv")

{

// print_r($_FILES['file_name']['tmp_name']);


$filename = $_FILES['file_name']['tmp_name'];


$handle = fopen($filename,'r');


$sql2="INSERT into

import(`file_name`,`timestamp`)values('".$fname."','".date('Y-m-d H:i:s')."')";


mysql_query($sql2);


$id = mysql_insert_id();


while (($data = fgetcsv($handle,1000, ","))!== FALSE)
{

//insert query to the database


$sql ="INSERT into import_sanmar


(`IMPORT_ID`,`UNIQUE_KEY`,`PRODUCT_TITLE`,`SPEC_SHEET`,`PRICE_TEXT`,

`SANMAR_MAINFRAME_COLOR`,`MILL`)

values('".$id."','".mysql_escape_string($data[0])."',

'".mysql_escape_string($data[1])."','".mysql_escape_string($data[2])."',

'".mysql_escape_string($data

[3])."','".mysql_escape_string($data[4])."','".mysql_escape_string($data[5])."','".my

sql_escape_string($data[6])."')";

//$sql2="INSERT into

import(`sel_file`,`timestamp`)values('$filename','".date('Y-m-d H:i:s')."')";

//$sql1=mysql_query("delete from import where UNIQUE_KEY=0");

mysql_query($sql) or die(mysql_error());

//mysql_query($sql2);

// to delete the first row of field name

//$sql1=mysql_query("delete from import_sanmar where IMPORT_ID=0");


$sql1=mysql_query("delete from import_sanmar where UNIQUE_KEY=0");

}




fclose($handle);

echo "Successfully Imported";
}

else

{

echo "Invalid File";

}

}
?>


form action="'' method='post' enctype="multipart/form-data">


import file: <input type="file" name="file_name" /><br />
<input type="submit" name="submit" />

/form>


by useing this script you can able to import the csv filedata to mysql database.