Wednesday, 17 December 2014

How to append csv file in php

<?php



function joinFiles(array $files, $result) {

$fp = fopen($result, "w");
$l=0;
foreach($files as $csv) {
  $row = 1;
  if (($handle = fopen($csv, "r")) !== FALSE) {
    while (($data = fgetcsv($handle, " ", ",")) !== FALSE) {
$line=array();
$datacount = count($data);
        // Add the data from the read csv file to the output array
if($l==0){
for($j=0;$j<$datacount;$j++){
$line[]=$data[$j];
}
fputcsv($fp, $line);
}else{
        if($row!=1){
for($j=0;$j<$datacount;$j++){
$line[]=$data[$j];
}
fputcsv($fp, $line);
}
}
      $row++;
    }
    fclose($handle);
  }
  $l++;
}
}

//Call function
joinFiles(array('csv1.csv', 'csv2.csv','csv3.csv'), 'finalcsv.csv');

?>

Wednesday, 5 November 2014

how to upload multiple file in wodpress in Meta Box

In Function.Php



//Add Metabox For Floor Plan
    add_action('post_edit_form_tag', 'update_edit_form');

    function update_edit_form() {
      echo ' enctype="multipart/form-data"';
      } // end update_edit_form

    add_action('add_meta_boxes', 'the_upload_metabox');
  
    function the_upload_metabox() { 
        // Define the custom attachment for posts 
        add_meta_box( 
            'wp_custom_attachment', 
            'Upload File', 
            'wp_custom_file_attachment','property'   
        );  
    }

    // The custom file attachment function
    function wp_custom_file_attachment() { 
     
      global $post;
      $theFILE=  get_post_meta($post->ID,'wp_custom_attachment',true);
     // $theFILE[0]['url']
   
     global $wpdb;

$media_file = get_post_meta( $post->ID, $key = '_wp_attached_file', true );
if(!empty($media_file)) { $theFILE = $media_file; }


      wp_nonce_field(plugin_basename(__FILE__), 'wp_custom_attachment_nonce'); 
      $html = '<p class="description">';
      $html .= 'Upload the File.';
      if(count($theFILE)>0 && is_array($theFILE)){
      $html.="Uploaded File:";

 foreach($theFILE as $sdds){

      ?>
       <img src="<?php echo $sdds['url']; ?>" width="50" height="50"  />
       <?php
   
       }
      }

$html .= '</p>';
$html .= '<input id="wp_custom_attachment" title="select file" multiple="multiple" name="wp_custom_attachment[]" size="25" type="file" value="" />'; 

    echo $html;
     
    }
     add_action('save_post', 'save_custom_meta_data');
    // Saving the uploaded file details
    function save_custom_meta_data($id) { 
        /* --- security verification --- */ 
        if(isset($_POST['wp_custom_attachment_nonce']))
        if(!wp_verify_nonce($_POST['wp_custom_attachment_nonce'], plugin_basename(__FILE__))) { 
          return $id; 
        } // end if 
           
        if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { 
          return $id; 
        } // end if 
         if(isset($_POST['post_type']))  
        if('page' == $_POST['post_type']) { 
          if(!current_user_can('edit_page', $id)) { 
            return $id; 
          } // end if 
        } else { 
            if(!current_user_can('edit_page', $id)) { 
                return $id; 
            }
        }
          
        // Make sure the file array isn't empty 
        if(!empty($_FILES['wp_custom_attachment']['name'])) {                        
            // Get the file type of the upload 
             $flag=0;
            for($i=0;$i<count($_FILES['wp_custom_attachment']['name']);$i++){
                if(!empty($_FILES['wp_custom_attachment']['name'][$i])){
                    $flag=1;
                // Use the WordPress API to upload the multiple files
                $upload[] = wp_upload_bits($_FILES['wp_custom_attachment']['name'][$i], null, file_get_contents($_FILES['wp_custom_attachment']['tmp_name'][$i])); 
                }
                }
                if($flag==1)
                update_post_meta($id, 'wp_custom_attachment', $upload);      
            
        }
         
    }

/************ Call On Display Page ***********/

<?php
        $imagess = get_post_meta($post->ID, 'uniplan_floorplan', false );
        foreach($imagess as $imgrow)
        {
        $imgurl=wp_get_attachment_url($imgrow);
        ?>
        <li><a href="<?php echo $imgurl; ?>" data-litebox-group="galone" class="litebox">
        <img class="a1" src="<?php echo $imgurl; ?>"alt="<?php echo $posts->post_title; ?>"></a></li>
        <?php
        } ?> 

Friday, 31 October 2014

How to Add a jQuery Accordion in WordPress

We provide a basic example to help you integrate Upcoming event show in your website with jQuery accordion code
Create costume event post, show only upcoming event, add meta tag


Function.php

 /********** Start Custom Termine ***********/
add_action('init','Termine');
function Termine()
{
     $labels = array(
        'name' => _x('Termine', 'post type general name'),
        'singular_name' => _x('Termine', 'post type singular name'),
        'add_new' => _x('Add New', 'Termine'),
        'add_new_item' => __('Add New Termine'),
        'edit_item' => __('Edit Termine'),
        'new_item' => __('New Termine'),
        'view_item' => __('View Termine'),
        'search_items' => __('Search Termine'),
        'not_found' =>  __('Nothing found'),
        'not_found_in_trash' => __('Nothing found in Trash'),
        'parent_item_colon' => ''
    );

    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'query_var' => true,
        'menu_icon' => admin_url(). '/images/termine.png',
        'rewrite' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'menu_position' => null,
        'supports' => array('title','editor','thumbnail')
       
      );
 register_post_type( 'Termine' , $args );
 }

add_action("admin_init", "admin_init");

function admin_init(){
add_meta_box("year_completed-meta", "Custom Field", "date_month", "Termine", "side", "low");
}

function date_month(){
global $post;
$custom = get_post_custom($post->ID);
$date = $custom["date"][0];
$time = $custom["time"][0];
$raum = $custom["raum"][0];

?>
 <link rel="stylesheet" href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
 <script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
<label>Date:</label>
<input name="date" id="datepicker" value="<?php echo $date;?>" />
<label>Time:</label>
<input name="time"  value="<?php echo $time;?>" />
<label>Raum:</label>
<input name="raum"  value="<?php echo $raum;?>" />

<?php
}
add_action('save_post', 'save_details');
function save_details(){
global $post;
update_post_meta($post->ID, "date", $_POST["date"]);
update_post_meta($post->ID, "time", $_POST["time"]);
update_post_meta($post->ID, "raum", $_POST["raum"]);

}


 /********** End Custom Termine ***********/


 In Front Page

 <div class="right-content">
            <h2>Termine</h2>
            <div class="inside detail_confirmation shrink2">
                <ul>
           
   

   
                <?php
                $termine = array( 'post_type' => 'Termine',
                                'meta_key' => date,
                                'orderby' => date, 'order'=> 'ASC','posts_per_page' => '5',
                    'meta_query' => array(
                                array(
                                    'key'        => 'date',
                                    'value'        => date('m/d/Y'),
                                    'compare'        => '>=',
                                ),
                            ),);
                            $termine = new WP_Query($termine);
                           
               
                        while ( $termine->have_posts()  ) : $termine->the_post();
                ?>
      
                   <li class="page_title">
                   
                   <div class="heading">
                  
                  <?php
                 
                    $date=get_post_meta($post->ID, 'date', true);
                      $d=date('d', strtotime($date));
                    $m=date('M', strtotime($date));
                    //$current=date('m/d/Y');
                    //if($current <= $date)
                    //{
                   ?>
                   <h3><?php echo $d;?>
                   <small><?php
                        switch ($m) {
                      case "Mar":
                        echo "Mär";
                        break;
                      case "May":
                        echo "Mai";
                        break;
                      case "Oct":
                        echo "Okt";
                        break;
                     case "Dec":
                        echo "Dez";
                        break;
                      default:
                        echo $m;
                        }
                        ?></small>
                   </h3><?php the_title();?></div>
                  <section class="booking_area children" style="display: none;">
                    <div class="inner-part">
                        <p><?php  echo substr($post->post_content,0,140);?></p>
          <p><a href="<?php echo the_permalink();?>" rel="bookmark"  style=" float: right;">weiterlesen...</a>
          <small style="float:left;color:#0190EC;"><?php echo get_post_meta($post->ID, 'time', true);?></small>
          </p>
       
                    </div>
                    </section>
                  </li>
                <?php // } ?>
                  <?php endwhile;  ?>
    <?php wp_reset_query(); ?>
                  
             </ul>
          </div>
           
           
          
               
                <div class="clients">
                   
                        <ul>
                    <?php  $partner = array( 'post_type' => 'Partner', 'order' => 'DESC' ,'posts_per_page' => 20);
                            $partner = new WP_Query($partner);
                        while ( $partner->have_posts() ) : $partner->the_post();
                        ?>
                        <?php $partner_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
                        <li><a href="<?php echo $post->post_content;?>" target="_blank"><img src="<?php echo $partner_image;?>" alt="<?php echo $partner_image;?>"/></a></li>
                       <?php endwhile;  ?>
                   <?php wp_reset_query(); ?>
                    </ul>
                  
                </div>
               
                   
        </div>
       

/*** Accordion.css ****/

.inside{float: left;margin-bottom: 20px;padding: 0 2% 0;width: 96%;}
.right-content h4 {margin-bottom: 18px;padding: 0 0 8px;color: #292929;font-family: open sans;font-size: 19px;font-weight: 600;background: url("../images/border.png") no-repeat scroll left bottom;}
li.page_title {
    background: url("../images/next1.png") no-repeat scroll 96% 18px #e7e7e7;
    border-top: 1px solid #f0f0f0;
    color: #000;
    cursor: pointer;
    float: left;
    font-size: 0.8em;
    margin: 0;
    padding: 0;
    text-decoration: none;
    text-transform: uppercase;
    width: 100%;
}
.active.page_title .heading {background:#fff; border:1px solid #e3e3e3; border-radius:4px;color: #191919;font-family: 'Open Sans', sans-serif; font-size:14px;}
.page_title .heading {
    float: left;
    width: 100%;
}
.heading h3 {
    background: none repeat scroll 0 0 #b8b8b8;
    display: inline-block;
    font-size: 16px;
    line-height: 16px;
    margin: 0 2% 0 0;
    min-width: 45px;
    padding: 8px;
    text-align: center;
    vertical-align: middle;
}
.heading h3 > small {
    display: block;
}
.page_title .booking_area {
    background: none repeat scroll 0 0 #f0f0f0;
    display: none;
    float: left;
    padding: 10px 3%;
    width: 94%;
}
.inner-part > p {
    font-family: "Lato";
    font-size: 14px;
    font-weight: 400;
    line-height: 23px;
    text-transform: none;
}
.detail_confirmation ul li.page_title .booking_area {display: none;}
.inner-part {float: left;padding: 20px 0;position: relative;width: 100%; background:#fff;}
.inner-part p{font-family: 'verdanaregular';font-size:12px; color:#191919;line-height: 18px;}
.inner-part .top_head {color: #676767;float: left;font-size: 16px;margin-bottom: 20px;width: 100%;}
.right-content .appointment .inner {padding: 0 3%;width: 94%;}
.right-content .appointment{float:left; width:100%;}
.right-content .appointment h4{color:#292929; font-size:20px;font-family: 'verdanaregular';}
.right-content .appointment p{color:#3c3a3a; font-size:12px;font-family: 'verdanaregular'; line-height:20px;}
.right-content .appointment li{border-bottom: 1px dotted #d2d2d2;display: block;padding: 11px 0;}
.right-content .appointment li img{ display: inline-block;vertical-align: middle;margin: 0 22px 0 0;}
.right-content .appointment li p{color:#010101; font-size:16px;font-family: 'verdanaregular';}
.right-content .appointment li p small{color:#3c3a3a; font-size:12px;}
.right-content .appointment li p a{color:#1f3159; font-size:16px; text-decoration:underline;}
.right-content .appointment li p a:hover{text-decoration:none;}
.row1 figure h2{
color: #797979;

/**** Accordion.js ****/
$(window).load(function(e) {
    $('.detail_confirmation ul li.page_title').children('.booking_area').hide();
    //$('.detail_confirmation ul li.page_title').eq(0).children('.booking_area').show();
});
$(document).ready(function(e) {   
    $('.detail_confirmation ul li.page_title .heading').click(function(e){
            $('.detail_confirmation ul li.page_title').removeClass('active');
            $(this).parent().addClass('active');
            $('.detail_confirmation ul li.page_title').children('.children').slideUp();
            $(this).siblings('.children').slideDown();
    });
});   


Also include following file from google
html5.js
jquery.js
reset.css


Tuesday, 24 June 2014

how to upload multiple images in php mysql

<?php
if($_FILES['Enginimage']['name'])
{
 foreach ($_FILES['Enginimage']['name'] as $name => $value)
    {
$source=$_FILES['Enginimage']['tmp_name'][$name];
   $target='uploads/'.time().stripslashes($_FILES['Enginimage']['name'][$name]);
$image_name= 'Engin#'.time().stripslashes($_FILES['Enginimage']['name'][$name]);
if (copy($source,$target))
           {
      $time=time();
  $carid=session_id();
 $queryimage="INSERT INTO photo(carId,image_name,modified_date) VALUES('$carid','$image_name','$time')";
      mysql_query("$queryimage");
  }
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<form method="post" id="EnginImage"  class="form-horizontal" enctype="multipart/form-data">
              <input type="file" name="Enginimage[]" multiple="true"/>
             <input type="submit" id="submited" name="submited" value="Image Upload"  />
            </form>
</body>
</html>

How to run database Query in WordPress?

<?php $wpdb->query('query'); ?>
// Examples
$wpdb->query(    "
    UPDATE $wpdb->posts
    SET post_parent = 7
    WHERE ID = 15
        AND post_status = 'static'    "
);

How to hide Directory Browsing in WordPress from server using .htaccess file?

Options -Indexes

How to hide the top admin bar at the frontend in WordPress

add_filter(‘show_admin_bar’, ‘__return_false’);

(or)
Add the below code in the active theme style.css stylesheet
#wpadminbar {
display: none; visibility: hidden;
}

Wednesday, 4 June 2014

Create testimonial custome function in wordpress

IN function.php

add_action('init', 'Testimonial');

function Testimonial() {

    $labels = array(
 'name' => _x('Testimonial', 'post type general name'),


'singular_name' => _x('Testimonial Item', 'post type singular name'),
        'add_new' => _x('Add New', 'Testimonial item'),
        'add_new_item' => __('Add New Testimonial Item'),
        'edit_item' => __('Edit Testimonial Item'),
        'new_item' => __('New Testimonial Item'),
        'view_item' => __('View Testimonial Item'),
        'search_items' => __('Search Testimonial'),
        'not_found' =>  __('Nothing found'),
        'not_found_in_trash' => __('Nothing found in Trash'),
        'parent_item_colon' => ''
    );

    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'query_var' => true,
        'menu_icon' => admin_url(). 'images/testimonial.png',
        'rewrite' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'menu_position' => null,
        'supports' => array('title','editor','thumbnail')
      );

    register_post_type( 'Testimonial' , $args );
}



In  front page you want to show testimonial

<div class="testimonial">
            <div class="testimonial_text">
                <span class="bottom_arrow"></span>
                <?php query_posts(array('showposts' => 1,'post_type' => 'Testimonial')); while (have_posts()) { the_post();
                    $pimage = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
                    ?>
                    <p><span><img src="<?php echo bloginfo('template_directory'); ?>/images/quot_img.png" alt="quot"></span><?php the_content(); ?> </p>
                    <?php } ?>
            </div>
            <div class="client_detail">
                <h4><strong>Pat Richie, Principal Consultant</strong><br>Table Group Consulting,</h4>
                <figure><img src="<?php echo bloginfo('template_directory'); ?>/images/client_img.png" alt="Client_1"></figure>
            </div>
        </div>

Tuesday, 3 June 2014

Create slider in wordpress

Function.php // write code  in function page

add_action( 'init', 'slider_home' );
function slider_home() {
    register_post_type( 'slider_home',
        array(
            'labels' => array(
                'name' => 'Slider',
                'singular_name' => 'Slider',
                'add_new' => 'Add New',
                'add_new_item' => 'Add New Slider',
                'edit' => 'Edit',
                'edit_item' => 'Edit Slider',
                'new_item' => 'New Slider',
                'view' => 'View',
                'view_item' => 'View Slider',
                'search_items' => 'Search Slider',
                'not_found' => 'No Slider found',
                'not_found_in_trash' => 'No Slider in Trash',
                'parent' => 'Parent Slider'
            ),

            'public' => true,
            'menu_position' => 15,
            'supports' => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields' ),
            'taxonomies' => array( '' ),
            'menu_icon' => admin_url( 'images/why_choose.png', __FILE__ ),
            'has_archive' => true
        )
    );
}


home page/ header.php // where you want to run slider

<ul>
     
        <?php $args = array('post_type' => 'slider_home' );
        $myposts = get_posts( $args );
       foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
          <li>
            <div class="slide-body" data-group="slide">
              <div class="container">
                <div class="wrapper">
                 <?php
                       
                        $slider1_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
                    
                        ?>
                  <div class="caption person" data-animate="slideAppearLeftToRight" data-delay="800"> <img src="<?php echo $slider1_image;  ?>" alt="Person"> </div>
                  <div class="caption problem_solved" data-animate="slideAppearLeftToRight">
                         
                       <?php echo $post->post_content; ?>
                        <a href="<?php the_permalink($post->ID); ?>">read more</a>
                  </div>
                 
                </div>
              </div>
            </div>
          </li>
          <?php endforeach;
          wp_reset_postdata();?>
         
        </ul>

Tuesday, 27 May 2014

List of MODI`S CABINET: मंत्रियों की सूची और उनके विभाग

राजनाथ सिंह : गृह मंत्रालय

सुषमा स्वराज : विदेश मंत्रालय, प्रवासी भारतीय मामलों का मंत्रालय

अरुण जेटली : वित्त, कॉरपोरेट मामला, रक्षा मंत्रालय

एम वेंकैया नायडू : शहरी विकास, आवास व शहरी गरीबी उन्मूलन, संसदीय कार्य मंत्रालय

नितिन गडकरी : सड़क परिवहन एवं राजमार्ग, जहाजरानी

डीवी सदानंद गौड़ा : रेलवे

उमा भारती : जल संसाधन, नदी विकास और गंगा पुनर्जीवन

नजमा ए हेपुल्ला : अल्पसंख्यक मामलों का मंत्रालय

गोपीनाथ राव मुंडे : ग्रामीण विकास, पंजायती राज, पेयजल व स्वच्छता

रामविलास पासवान : उपभोक्ता मामला, खाद्य व सार्वजनिक वितरण

कलराज मिश्र : सूक्ष्म, लघु और मध्यम उद्यम

मेनका गांधी : महिला व बाल विकास विभाग

अनंत कुमार : रासायनिक व उवर्रक

रविशंकर प्रसाद : संचार और सूचना प्रौद्योगिकी, कानून व न्याय

अशोक गजपति राजू पसुपति : नागरिक उड्डयन

अनंत गीते : भारी उद्योग व सार्वजनिक उद्यम

हरसिमरत कौर बादल : खाद्य प्रसंस्करण उद्योग

नरेंद्र सिंह तोमर : खनन, इस्पात, श्रम एवं रोजगार

जुआल ओरांव : जनजातीय मामला

राधा मोहन सिंह : कृषि

थवर चंद गहलोत : सामाजिक न्याय व अधिकारिता

स्मृति ईरानी : मानव संसाधन विकास

हर्षवर्धन : स्वास्थ्य व परिवार कल्याण


राज्य मंत्री :

जनरल (सेवानिवृत्त) वीके सिंह : पूर्वोत्तर क्षेत्रों का विकास (स्वतंत्र प्रभार), विदेश मंत्रालय, प्रवासी भारतीय मामलों का मंत्रालय

इंद्रजीत सिंह राव : नियोजन (स्वतंत्र प्रभार), सांख्यिकी व कार्यक्रम क्रियान्वयन (स्वतंत्र प्रभार), रक्षा

संतोष कुमार गंगवार : कपड़ा (स्वतंत्र प्रभार ) संसदीय कार्य मंत्रालय, जल संसाधन, नदी विकास और गंगा पुनर्जीवन

श्रीपद येसो नाइक : संस्कृति (स्वतंत्र प्रभार), पयर्टन (स्वतंत्र प्रभार)

धर्मेद्र प्रधान : पेट्रोलियम व प्राकृतिक गैस (स्वतंत्र प्रभार)

सर्बनंद सोनोवाल : कौशल विकास, उद्यमशीलता, युवा मामले व खेल (स्वतंत्र प्रभार)

प्रकाश जावड़ेकर : सूचना व प्रसारण (स्वतंत्र प्रभार), पर्यावरण, वन एवं जलवायु परिवर्तन (स्वतंत्र प्रभार), संसदीय मामला

पियूष गोयल : विद्युत (स्वतंत्र प्रभार), कोयला (स्वतंत्र प्रभार), नवीन व नवीनीकृत ऊर्जा (स्वतंत्र प्रभार)

जितेंद्र सिंह : विज्ञान व प्रौद्योगिकी (स्वतंत्र प्रभार), भू विज्ञान (स्वतंत्र प्रभार), प्रधानमंत्री कार्यालय, कार्मिक, लोक शिकायत व पेंशन, आण्विक ऊर्जा विभाग, अंतरिक्ष विभाग

निर्मला सीतारमन : वाणिज्य व उद्योग (स्वतंत्र प्रभार), वित्त, कॉरपोरेट मामला

जीएम सिद्देश्वरा : नागरिक उड्डयन

मनोज सिन्हा : रेलवे

निहालचंद : रासायनिक व ऊवर्रक

उपेंद्र कुशवाहा : ग्रामीण विकास, पंचायती राज, पेयजल एवं स्वच्छता

पी राधाकृष्णन : भारी उद्योग व सार्वजनिक उद्यम

किरन रिज्जु : गृह मंत्रालय

कृष्ण पाल : सड़क परिवहन एवं राजमार्ग, जहाजरानी

संजीव कुमार बलयान : कृषि, खाद्य प्रसंस्करण उद्योग

मनसुखभाई धंजीभाई वासवा : जनजातीय मामला

रावसाहेब दादराव दान्वे : उपभोक्ता मामला, खाद्य व सार्वजनिक वितरण

विष्णु देव साईं : खनन, इस्पात, श्रम व रोजगार

सुदर्शन भगत : सामाजिक न्याय व अधिकारिता

Saturday, 17 May 2014

How to Send Mail In PHP Code

function seMail($to,$from,$subject,$message){
  $headers = "MIME-Version: 1.0\r\n";
        $headers .= "Content-type: text/html; charset=iso-8859-1". "\r\n";
        $headers  .= "From: $from\r\n";
        mail($to, $subject, $message, $headers);
 }

if($_POST['submit'])
  {
    $pid= $_REQUEST[pid]
    $price= $_REQUEST[price]
    $weight= $_REQUEST[weight]
    $qty= $_REQUEST[qty]
    $firstname= $_REQUEST[firstname]
    $lastname= $_REQUEST[lastname]
    $road= $_REQUEST[road]
    $pincode= $_REQUEST[pincode]
    $place= $_REQUEST[place]
    $land= $_REQUEST[land]
    $mail= $_REQUEST[mail]
    $phone= $_REQUEST[phone]
    $comment= $_REQUEST[comment]
    $page= $_REQUEST[page]
    $files= $_REQUEST[files]
    $PHPSESSID= $_REQUEST[PHPSESSID]
    $message="Here Your HTML EMAIL Templet";

//=================== msg for  sale ===================
seMail($mail,"satyam@fastconversion.com","Thanks for Contact Us",$message);
$thankMsg="Thank You For Contact Us.";
 } ?>

Friday, 16 May 2014

change password code in php

<?php
include('conn.php');

if(isset($_POST['loging']))
{
$query="select * from fersh_html where password='".$_POST['password']."'";
$result=mysql_query($query) or die(mysql_error());
$count=mysql_num_rows($result);
$row=mysql_fetch_object($result);
if($count>0)

    {
$update="update fersh_html set password='".$_POST['npassword']."' where id='$row->ID'";

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

header('location:newtest.php');

}
else
    {

echo $error_msg='please eneter curret password';

}
}
?>

How to delete particular row value in sql

<?php
include('conn.php');
$query="delete from table_name where ID='$_REQUEST[id]'";
mysql_query($query) or die(mysql_error());
header('location:category_fetch.php');
?>

logout code in php

<?php
session_start();
$_SESSION['ID']=='';
unset($_SESSION['ID']);
session_destroy;
header('location:index.php');
?>

login code in php using mysql

<?php

include('conn.php');
session_start();
if(isset($_POST['submit']))
{
$query="select * from login where Username='".$_POST['username']."' and Password='".$_POST['Password']."'";
$result=mysql_query($query) or die(mysql_error());
$row=mysql_fetch_object($result);
$count=mysql_num_rows($result);
if($count>0)
    {
    $_SESSION['ID']=$row->ID;
    $_SESSION['Username']=$row->username;
   
    header('location:category_add.php');
    }
else
    {
echo $error_msg="invalid user name or password";
}

}
?>

Radio buttons and checkboxes in html with php

<input type="radio" <?php if($row->status=='Active') {echo 'checked=checked';} ?> name="status" id="status" value="Active">Active
<input type="radio" <?php if($row->status=='Inactive') {echo 'checked=checked';} ?>  name="status" id="status" value="Inactive">Inactive</td>

Data fetch from database in php in special conditions

<?php
$i=1;
while($row=mysql_fetch_object($result))
{
?>
<tr>
<td align="center"><?php echo $i; ?></td>
<td align="center"><img src="<?php echo $row->image; ?>" height="45" width="60" /></td>
<?php
$querya="select * from catagory where id='$row->Catagory'";
$resulta=mysql_query($querya) or die (mysql_error());
$rowa=mysql_fetch_object($resulta);
?>
<td align="center"><?php echo $rowa->name; ?></td>
<?php
$queryc="select * from subcatagory where id='$row->Subcatagory'";
$resultc=mysql_query($queryc) or die (mysql_error());
$rowc=mysql_fetch_object($resultc);
?>
<td align="center"><?php echo $rowc->name; ?></td>
<td align="center"><?php echo $row->name; ?></td>
<td align="center"><?php echo $row->price; ?></td>
<td align="center"><?php echo $row->sku; ?></td>
<td align="center"><?php echo $row->description; ?></td>
<td align="center"><?php echo $row->date; ?></td>
<td align="center"><a href="product_edit.php?id=<?php echo $row->id; ?>">EDIT</a> | <a href="product_delete.php?id=<?php echo $row->id; ?>" onclick="return confirm('Are You Sure To Delete')">DELETE</a></td>
 </tr>
<?php
$i++;
}
?>

Data fetch from database in php

<?php
$query="select * from name of table";
$result=mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_object($result))
            {
            ?>
           <tr>
           <td align="center"><?php echo $row->ID; ?></td>
           <td align="center"><?php echo $row->Name; ?></td>
              <td align="center"><?php echo $row->Title; ?></td>
            <td align="center"><img src="<?php echo $row->Image; ?>" height="80" width="80>"></td>
            <td align="center"><?php echo $row->Descripation; ?></td>
            <td align="center"><a href="category_edit.php?id=<?php echo $row->ID; ?>">Edit</a><a href="category_del.php?id=<?php echo $row->ID; ?>">Delete</a></td>
         </tr>
            <?php
            }
            ?>

FORM methods in html

 <form method="post" enctype="multipart/form-data">
 form close always end of body
</form>

Wednesday, 14 May 2014

Inserting in database with image using php

<?php

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

    if($_FILES['image']['name'])
        {
        $target='images/'.$_FILES['image']['name'];
        $source=$_FILES['image']['tmp_name'];
        copy($source,$target);
        }
        $query="insert into name of table set Name='".$_POST['name']."',Title='".$_POST['title']."',Descripation='".$_POST['description']."',image='$pname'";
        mysql_query($query) or die(mysql_error());
        }
?>

Database connection in php using mysql

<?php
$db=mysql_connect('localhost','root','');
mysql_select_db('userinfo',$db);
?>

How to fetch random data from database

$query="SELECT * FROM product ORDER BY RAND( )LIMIT 0 , 5 ";
$result=mysql_query($query);

how to change date format in mysql using php

$currentDateFrom=date('Y-m-d',strtotime($currentDate)-24*60*60);

How can i get the current id number in mysql

mysql_insert_id()

Get number of updated rows in in mysql

Mysql_affected_rows();

How can I get special characters out of a mysql

before you execute the query in PHP use this code
mysql_set_charset('utf8');