wordpress_add

Tuesday, 19 November 2013

Count files in any directory using php..!!

Dr-Wordpress : how to count the number of files in any directory using php.


<?php 
    //Counts starts at 0
    $i = 0; 
    $dir = 'images/Trip_images/';
    if ($handle = opendir($dir)) {
        while (($file = readdir($handle)) !== false){
            if (!in_array($file, array('.', '..')) && !is_dir($dir.$file)) 
                $i++;
        }
    }
    // print count files in directory
    echo "There were $i files";
?>


Subscribe Dr-Wordpress for Important Knowledge of wordpress..your's suggestions are most welcomed.

Friday, 15 November 2013

How to Display Child Category name and link in Wordpress.

One line code for displaying child category with relevant link. Dr-Wordpress
 DISPLAY CHILD CATEGORY IN WORDPRESS....!!! (dr-wordpress)

NOTE : "3" IS THE ID OF PARENT CATEGORY

<?php wp_list_categories('orderby=id&show_count=1&use_desc_for_title=0&child_of=3'); ?>

Subscribe Dr-Wordpress for Important Knowledge of wordpress..your's suggestions are most welcomed.

Tuesday, 12 November 2013

MySQL Update Query In php..!!!

Dr-Wordpress : easy way to use update query in MySQL ( php )....!!!

<?php
ob_start();

 $db_name = 'database_name';
  $db_user = 'root';
  $db_pass = '';
 $db_host = 'localhost';
 $connection = mysql_connect($db_host, $db_user, $db_pass);
  mysql_select_db($db_name);

 ?>


$sql = "UPDATE $tablename  SET $column_name = '$value' WHERE Id='$id'";

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


Subscribe Dr-Wordpress for Important Knowledge of wordpress..your's suggestions are most welcomed.

How to get the value of radio button.!!!

Dr-Wordpress : through Php How to get the value of radio button...!!!

<form name="my form" method="POST" action="validate.php"> 
<label >
  <input type="radio" id="id_radio1" name="name_radio" value="1"/>Dr-wordpress 1</label>
<label>
    <input type="radio" id="id_radio2" name="name_radio" value="2"/>Dr-wordpress 2</label>
<label>
     <input type="radio" id="id_radio3" name="name_radio" value="3"/>Dr-wordpress 3</label>

<input type="submit">

</form>

NOTE : Must gave the value in input tag other wise just ON/OFF will display 

<?php

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

{
    echo $radio_value1 = $_POST["name_radio"];
}
?>


Subscribe Dr-Wordpress for Important Knowledge of wordpress..your's suggestions are most welcomed.

Friday, 8 November 2013

jquery show/hide Effect with radio button...!!!

Jquery show/hide Effect with radio button

In dr-wordpress Today i going to share an important example of jquery.
I am Also badly stuck, when i am doing this.
So i am sharing this code with you people..
<!-----------------------------------------------HTML CODE------------------------------------>
<form>
<input id="id_radio1" type="radio" name="name_radio" value="value_radio1" checked="checked"/>Radio1

<input id="id_radio2" type="radio" name="name_radio" value="value_radio2" />Radio2

<input id="id_radio3" type="radio" name="name_radio" value="value_radio3" />Radio3
                 
</form>
              <div id="divs">
                   <div id="div1">One</div>
                   <div id="div2">Two</div>
                   <div id="div3">Three</div>     

              </div>
<!-----------------------------------------------CSS CODE----------------------------------------->
#divs div {
    display:none;

}
<!-----------------------------------------------Jquery CODE-------------------------------------->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
 $(function() {
          var $divs = $('#divs > div');
          $divs.first().show()
          $('input[type=radio]').on('change',function() {
                  $divs.hide();
                  $divs.eq( $('input[type=radio]').index( this ) ).show();
           });

});
<script>


Subscribe Dr-Wordpress for Important Knowledge of wordpress..your's suggestions are most welcomed.

Thursday, 7 November 2013

DR-WORDPRESS : How to make responsive design through media query.

At different resolution some time we need different style ( css ) for a particular div or span etc so we use media query for it.


NOTE: 980px means That less than 980px resolution   this is style is active.

 @media screen and (max-width: 980px) {

#header .inner 
{
    float: left;
    padding-left: 0px;
    width: 475px;
}

 }


Subscribe Dr-Wordpress for Important Knowledge of wordpress..your's suggestions are most welcomed.