Wednesday, 3 September 2014

Foreach loop in CI - Array value display

To display Array values from control ( more than 1 row or records) PHP

use foreach($arravar as $arr) :

 <?php foreach($schedule as $sched) { $sched['col_name'] }
    ?>

End once all records are showed

-------------------------------------------------------------------

To display Array values from control only 1 row

use $arravar[0]['col_name']
 <?php echo $schedule[0]['schedule_child_id']; ?>
                              

To display Array values from control ( more than 1 row or recods)

To display Array values from control ( more than 1 row or records) PHP

use foreach($arravar as $arr) :

 <?php foreach($schedule as $sched) { $sched['col_name'] }
    ?>

End once all records are showed

-------------------------------------------------------------------

To display Array values from control only 1 row

use $arravar[0]['col_name']
 <?php echo $schedule[0]['schedule_child_id']; ?>
                              

Thursday, 28 August 2014

Array filter with Implode process - PHP

 Array filter with Implode process :

<?php
$chat_list=array(0,1,2,3,4,5,0,4,2,3);  // This array have duplicates

$user=array();

foreach($chat_list as $key=>$chat)
{
 $user[$key]=$chat['UserName'];
}

 print_r(implode(' , ',array_unique($user))); //This will show unique and added comma for each element.

 ?>

PHP Array filter working code


Array filter does not allow duplicate values:

<?php
$array = array(1, "hello", 1, "world", "hello");

$new=array_filter(array_count_values($array),'custom_filter');

print_r($new);

function custom_filter($val)
{
  return $val > 1;
}

?>

HTML Image Zoom Js function

<!doctype html>
<html>

<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

<script type="text/javascript" src="http://www.dynamicdrive.com/dynamicindex4/jquery.magnifier.js">

/***********************************************
* jQuery Image Magnify- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/

</script>

</head>

<body>
<img src="icon.jpg" class="magnify" style="width:200px; height:150px" />

<img src="logo.jpg" class="magnify" border="0" />
</body>
</html>

HTML video play

HTML Video Play Control : 

<html>
<head>
  </head>
<body>

  <video id="example_video_1" class="video-js vjs-default-skin" controls preload="none"
 width="450" height="264"       data-setup="{}">
   
    <source src="v1.mp4" type='video/mp4' />
   
    <video src="v1.mp4" controls autoplay loop muted preload="auto" poster="demo.jpg" >
HTML5 Video is required for this example
 
  </video>

</body>
</html>

required JS for Phonenumber validation accept + -

Text field validation keep data after submit use required="required"
--------------------------------------------------------------------

Article:2
<input type="text" id="" name="phone" onkeypress="return onlyNos(event,this);" maxlength="15" required="required">

<script language="Javascript" type="text/javascript">

        function onlyNos(e, t) {

            try {

                if (window.event) {

                    var charCode = window.event.keyCode;

                }

                else if (e) {

                    var charCode = e.which;

                }

                else { return true; }

                if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode > 43 && charCode > 45) {

                    return false;

                }

                return true;

            }

            catch (err) {

                alert(err.Description);

            }

        }



    </script>

Image Upload When click on sample image HTML PHP

html:

<input id="profile-image-upload" class="hidden" type="file">
<div id="profile-image">click here to change profile image</div>

js:

$(function() {
    $('#profile-image').on('click', function() {
        $('#profile-image-upload').click();
    });
});

   
css:

input.hidden {
    position: absolute;
    left: -9999px;
}

#profile-image {
    cursor: pointer;
    background: #8adffb;
     width: 80px;
    height: 80px;
}

Ref : jquery1.9.1
REF: http://jsfiddle.net/L8xCb/3/

working code:


<div id="profile-image1"><img  src="<?php echo $image1; ?>" ></div>
 <input id="profile-image-upload1" class="hidden" type="file" name="file1"></input>

We can add more than one image image1,image2 at css,js files.

Footer Fixed at bottom possible without jQuery

Footer fixed bottom position

I have a page with only a couple of lines of content. I want the footer to be pushed to the bottom.

<div id="footer"></div>

I don't want to use #footer{ position:fixed;bottom:0; } AKA Sticky Footer

Is this possible without jQuery?

ThaX for REf link:    http://stackoverflow.com/questions/16679146/force-footer-on-bottom-on-pages-with-little-content
<html>
    <head>
        <link rel="stylesheet" href="layout.css" ... />
    </head>
    <body>
        <div class="wrapper">
            <p>Your website content here.</p>
            <div class="push"></div>
        </div>
        <div class="footer">
            <p>Copyright (c) 2008</p>
        </div>
    </body>
<style>

* {
margin: 0;
}
html, body {
height: 100%;
}
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -4em;
}
.footer, .push {
height: 4em;
}
</style>
</html>

Dynamic Text Box add edit and delete and change HTML PHP

Dynamic Text Box add edit and delete and change that values as Array format and store in single column with comma(,) seperator.
Addform.php:
-------------
<?php
<script src="admin/js/jquery-1.11.1.js" ></script>

<form action="adddata.php" method="post" name="addevents"
 <td rowspan="2" style="border:1px solid #ccc;overflow:auto;">
    <div style="overflow:auto;">
    Latitude : <input type="text" name="latitude[]"   />
    Longitude : <input type="text" name="longitude[]"    />
    <input type="button" onclick="addFormField()" value="add" /><br>
   
   
    <div id="MoreFiles">
    </div>
   
<script type="text/javascript" language="javascript">
  var id = 1;
  function addFormField() {
 
      if(id < 100){
        
     
      jQuery("#MoreFiles").append("<div class='spacer'></div><div class='AdmFleft'>
      <div id='row"+id+"'><div class='control-group'>
      <div class='controls'>
      <label class='control-label' for='focusedInput'>Latitude : <input class='input-xlarge focused'  type='text' value='' name='latitude[]'>&nbsp;
      <label class='control-label' for='focusedInput'>Longitude : <input class='input-xlarge focused'  type='text' value='' name='longitude[]'>
      <a href='#' onClick='removeFormField(\"#row"+id+"\"); return false;'>DELETE</a></div></div></div></div>");
      id++;
      //id = (id-1) + 2;
      //document.getElementById('id').value = id;
     // datep();
      }
      else
        alert('Limit Reached');
     
  }
  function removeFormField(id) {
  alert(id);
     
      jQuery(id).remove();
  }

</script>
</td>
</form>
?>

adddata.php:
============
<?php

$lat=$_POST["latitude"];
$long=$_POST["longitude"];
foreach($lat as $latitude)
{
 $item1 .= $latitude.',';
}
foreach($long as $longitude)
{
 $item2 .= $longitude.',';
}
$latitude=substr($item1,0,-1);
$longitude=substr($item2,0,-1);
//$longitude0.','.$longitude1.','.$longitude2.','.$longitude3.','.$longitude4;
//insert  into $latitude......,

?>

================================
editform.php:
-------------


$id = $_GET['id'];
$query=mysql_query("select * from events where eventid=$id");
$res = mysql_fetch_assoc($query);

<td rowspan="2" style="border:1px solid #ccc;">
   
    <?php $latitude=explode(',' ,$res["latitude"]);  $longitude=explode(',' ,$res["longitude"]); ?>
    <?php foreach($latitude as $key => $lat1) { if($latitude[0] == $latitude[$key]) { ?>
   
    Latitude : <input type="text" name="latitude[]" id="latitude0"  value="<?php if(isset($lat1)){ echo $lat1;} else{ echo ''; }; ?>"  />
    Longitude : <input type="text" name="longitude[]" id="longitude0"   value="<?php if(isset($longitude[$key])) { echo $longitude[$key];} else{ echo ''; }; ?>"/>
        <input type="button" onclick="addFormField()" value="add" /><?php }
        else{?> <div id=<?php echo $key; ?>'>
       
    <div id="MoreFile">
    <div class="spacer"></div><div class="AdmFleft"><div id="rows<?php echo $key;?>"><div class="control-group"><div class="controls"><label for="focusedInput" class="control-label">Latitude : <input type="text" name="latitude[]" value="<?php if(isset($lat1)){ echo $lat1;} else{ echo ''; }; ?>" class="input-xlarge focused">&nbsp;<label for="focusedInput" class="control-label">Longitude : <input type="text" name="longitude[]" value="<?php if(isset($longitude[$key])) { echo $longitude[$key];} else{ echo ''; }; ?>" class="input-xlarge focused"><a onclick="removeFormField1(rows<?php echo $key;?>); return false;" href="#">DELETE</a></label></label></div></div></div></div></div>
                <?php } } ?>
       
        <div id="MoreFiles">
    </div>
   
   
<script type="text/javascript" language="javascript">

  var id = 1;
  function addFormField() {
 
      if(id < 100){
     
      jQuery("#MoreFiles").append("<div class='spacer'></div><div class='AdmFleft'><div id='row"+id+"'><div class='control-group'><div class='controls'><label class='control-label' for='focusedInput'>Latitude : <input class='input-xlarge focused'  type='text' value='' name='latitude[]'>&nbsp;<label class='control-label' for='focusedInput'>Longitude : <input class='input-xlarge focused'  type='text' value='' name='longitude[]'><a href='#' onClick='removeFormField(\"#row"+id+"\"); return false;'>DELETE</a></div></div></div></div>");
      id++;
      //id = (id-1) + 2;
      //document.getElementById('id').value = id;
     // datep();
      }
      else
        alert('Limit Reached');
     
  }
  function removeFormField(id) {
  //alert(id);
     
      jQuery(id).remove();
  }
   function removeFormField1(id) {
  alert(id);
     
      jQuery(id).remove();
  }


</script>
    </td>
-----
edit_event_process.php
Same thing follow in add details....

HTML Time Picker

Dowload files link : http://curioussolutions.github.io/DateTimePicker/



HTML TimePicker Example Snippet:

<!DOCTYPE html>

<html>

   
<head>
   

<title>Time Picker</title>

<link rel="stylesheet" type="text/css" href="../src/DateTimePicker.css" />
   


<script type="text/javascript" src="jquery-1.11.0.min.js"></script>
   
<script type="text/javascript" src="../src/DateTimePicker.js"></script>
   

<!--[if lt IE 9]>
           
<link rel="stylesheet" type="text/css" href="../src/DateTimePicker-ltie9.css" />

<script type="text/javascript" src="../src/DateTimePicker-ltie9.js"></script>

<![endif]-->
       


<style type="text/css">

p{
margin-left: 20px;

}


input{
width: 200px;

padding: 10px;

margin-left: 20px;
   
margin-bottom: 20px;

}

</style>
       

</head>
   

<body>
   

<p>Time : </p>
<input type="text" data-field="time" readonly>
   
<div id="timeBox"></div>
   
<input type="text" data-field="date" readonly>

<div id="dateBox"></div>

<script type="text/javascript">
   
$(document).ready(function()
   
{
$("#timeBox").DateTimePicker();
   
$("#dateBox").DateTimePicker();
    });

</script>
   

</body>

s
</html>

Redux vs Redux Toolkit vs React Context

  These are often confused. Feature Redux Redux Toolkit Context API Purpose State management Simplifies Redux Shares values in Rea...