Tuesday, 27 November 2012

how to insert,select,delete,update data from file in c?

Download example file :   example.c

Compiled on : Borland Turbo C++ 3.0

Wednesday, 31 October 2012

how to refresh particular div tag content without reloading page using jquery?

// Note : First include jquery.js file.....
<script type="text/javascript">
var auto_refresh = setInterval(
function ()
{
$('#load_div').load('load.php').fadeIn("slow");
}, 100000); // refresh every 10000 milliseconds
</script>

//index.php

<div id="load_div">
</div>

//load.php

In this page you can write your code.
like load randam user,image etc....

Tuesday, 23 October 2012

How to pass data from one domain to another domain(cross domain) using json?‏

//Javascript code

<script type="text/javascript">

$(document).ready(function()
{

var surl =  "http://www.example.com/json.php";

email_id=document.getElementById("email").value;

$.ajax({
url: surl,
data: {email:email_id},
dataType: "jsonp",
jsonp : "callback",
jsonpCallback: "jsonpcallback"
});
});

function jsonpcallback(rtndata)
{
document.getElementById("disp_data").innerHTML=rtndata.message;
}

</script>

//json.php file code

<?php

$display="<b>HI Json</b>";

$display.="<p>HI This is testing json.</p>";

$rtnjsonobj->message = $display;

echo $_GET['callback']. '('. json_encode($rtnjsonobj) . ')';

?>

Tuesday, 16 October 2012

error page using htaccess file

first create .htaccess  file and save it.

then write below code

ErrorDocument 404 /404.html

 

here

404 means when page not found then it occurs

404.html means that page which you want to display.

 

 

Thursday, 6 September 2012

How to convert timestamp to date in MYSQL with where clause?

SELECT * , DATE( FROM_UNIXTIME( `time_stamp` ) ) AS sBdat
FROM phpfox_feed
WHERE DATE( FROM_UNIXTIME( `time_stamp` ) ) = '2012-09-05'

How to convert timestamp to date in MYSQL?

MYSQL:

SELECT DATE( FROM_UNIXTIME( `time_stamp` ) ) AS sBdat FROM users

 

OUTPUT:

2012-09-06

Tuesday, 24 July 2012

how to check element visibility in jquery?

example of element exists and it’s not visible


<div id="test">
<div id="test_1" style="display:none">
Hello World!
</div>
</div>


jQuery code:
if ($('#test_1:visible').length > 0)
{
alert('the element is visible');
}
else
{
alert('the element is not visible');
}


Tuesday, 3 July 2012

how to replace & or special characters in javascript?

//if  value of catnm='art & jewllery';

//then i want need to replace "&".

//because when i will try to post data using jquery then jquery know this is query string.....so i want to need  to replace "&"  using "URL ENCODED CHARACTERS"

//so,see below example

var catnm=document.getElementById('catnm').value;

var cat_re=catnm.replace('&','%26');

OUTPUT 

In Javascript alert box  : art %26 jewllery

In html format(in web browser )  : art & jewllery

Please refer below website for URL Encode Characters

http://www.degraeve.com/reference/urlencoding.php

http://www.w3schools.com/tags/ref_urlencode.asp

Friday, 27 April 2012

how to validate multiple select box with jquery?

$("#form").validate({
rules:{
"select_esp[]": "required"
},
messages:{
"select_esp[]": "Select this"
}
});

 

Saturday, 14 April 2012

How to enable/disable element in Javascript

If u want to enable or disable any HTML element using javascript in asp.net/php u can use the following code,

document.getelementbyid('nm').disabled='disabled' ;


and the below code will enable the element,

document.getelementbyid('nm').disabled='';

Tuesday, 3 April 2012

how to make captcha in php?

Captcha Code:

<?php
session_start();

$num='';

$string = "abcdefghijklmnopqrstuvwxyz0123456789";
for($i=0;$i<7;$i++){
$num1=rand(0,35);
$num .= $string{$num1};
}

$_SESSION["num1"]=$num;

$img=imagecreatefrompng('captcha.png');
$color=imagecolorallocate($img,255,255,255);
$color1=imagecolorallocate($img,0,0,0);
imagestring($img,9,10,3,$num,30);
$fontsize=20;
$fontcolor = imagecolorallocate($img, 0, 0, 0);
$x = 0;
$y = $fontsize;

header('Content-type : image/png');
imagepng($img);
imagedestroy($img);

?>

How to use in php?

<img id="cap" style="margin-left: 15px;" src="comman/captcha.php" alt="" />

How to refresh captcha?

Call the below function  onclick

<script >
function captcha()
{
document.getElementById('cap').src = document.getElementById('cap').src+ '?';
}
</script>

Save as captcha.png file

Monday, 2 April 2012

how to check path of ffmpeg or mencoder in linux in php?

<?php
$output = shell_exec('whereis ffmpeg');
echo "<pre>".$output."</pre>";
echo "";

$output = shell_exec('whereis mencoder');
echo "<pre>".$output."</pre>";
echo "";
?>

Output in browser :

Monday, 26 March 2012

How to launch jQuery Fancybox on page load?

//first include fancybox javascript file and jquery javascript file.

<script type="text/javascript">

jQuery(document).ready(function() {
$("a#various2").trigger('click');
});
</script>

Friday, 23 March 2012

how to remove any character using javascript?

I am removing only " - (dash), . (dot), (space) in this exmple.

function dotrm(cit)
{
var cl=cit.length;
var ch=cit;
for(l=0;l<=cl;l++)
{
if(cit[l] == '.' || cit[l] == ' ' || cit[l]=='-')
{
ch=cit.replace(cit[l],'');
}
}
document.getElementById("city").value=ch;
}

Saturday, 17 March 2012

how to backup mysql database using php?

<?php
$backfile="a.sql";
$command="mysqldump  -u root test>$backfile";//
system($command);
?>

Friday, 16 March 2012

how to validate password allow space in middle of string

function spc(str)
{
var l=str.length;//check length of string
for(var i=0;i<l;i++)
{
if(str[0]==' ' || str[str.length-1]==' ')//check first & last character of password
{
document.getElementById("spa_error").innerHTML='Space key cannot be used for the first or last character of your password';
}else
{
document.getElementById("spa_error").innerHTML='';
}
}
}

Monday, 12 March 2012

how to use trim() function in IE below version

Use this function in head section of your webpage and then use trim() function.

if(typeof String.prototype.trim !== 'function') {
  String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g, '');
  }
}

Saturday, 10 March 2012

How to add top and bottam pagination in datatable?

First open  jquery.datatables.js file and find   this.sDom = 'lfrtip'; or this.sDom  and then write below code inplace of previous code.

this.sDom = '<"top"iflp>t<iflp>';

 

How to validate multiple checkbox?

var adfa=0;
var chk=document.getElementById("tbl");//table id
for(var i=0;i < chk.rows.length;i++)
{
var inputs = chk.rows[i].getElementsByTagName('input');
if(inputs[0].checked==true)
{
adfa=1;
}
}
if(adfa==1)
{
//alert("true");
if(val=='delete'){
var ans=confirm('Are you sure want to delete?');
if(ans)
document.forms[id].submit();
}
}else
{
alert("No entry was selected to be deleted");
}

Saturday, 3 March 2012

PHP mail with attachment

<?php

//Set Email Subject
$subject = $_POST['sub'];
$message_email=$_POST['message'];
$message_email.='<br><br><br>'.$data;

//define the from \ reply to headers
$headers = "From: darshakkumarshah@mkics.in\r\nReply-To: darshakkumarshah@mkics.in";

//create a unique boundary string to delimit different parts of the email (plain text, html, file attachment)
$random_hash = md5(date('r', time()));

//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";

//read the atachment file contents into a string,
//encode it with MIME base64,
//and split it into smaller chunks for sending
$attachment = chunk_split(base64_encode(file_get_contents($file_nm)));

//define the body of the message.
$message = "--PHP-mixed-$random_hash\r\n"
."Content-Type: multipart/alternative; boundary=\"PHP-alt-$random_hash\"\r\n\r\n";
$message .= "--PHP-alt-$random_hash\r\n"
."Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"
."Content-Transfer-Encoding: 7bit\r\n\r\n";

//Insert the plain text message.
$message .= strip_tags($data);
$message .= "\r\n\r\n--PHP-alt-$random_hash\r\n"
."Content-Type: text/html; charset=\"iso-8859-1\"\r\n"
."Content-Transfer-Encoding: 7bit\r\n\r\n";

//Insert the html message.
$message .= $message_email;
$message .="\r\n\r\n--PHP-alt-$random_hash--\r\n\r\n";

//include attachment
if(isset($_POST['checkbox']))
{
$message .= "--PHP-mixed-$random_hash\r\n"
."Content-Type: application/pdf; name=".$file_nm."\r\n"
."Content-Transfer-Encoding: base64\r\n"
."Content-Disposition: attachment\r\n\r\n";
$message .= $attachment;
$message .= "/r/n--PHP-mixed-$random_hash--";
}

//send the email
$mail = mail( $to, $subject , $message, $headers );

?>

Tuesday, 31 January 2012

Dynamic add and remove Textbox with numeric validation using javascript

<script type='text/javascript'>
// Numeric validations
function numbersonly(e){
var unicode=e.charCode? e.charCode : e.keyCode
if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
if (unicode<48||unicode>57) //if not a number
return false //disable key press
}
}

// remove dynamic textbox
function rem(inval)
{
$("#my"+inval+"Div").remove();
}
// add dynamic textbox
// --------------------------------------------------------
// Author : Daxa
// Website : http://www.beyondmart.com/
// modify by : darshakkkumar shah
// modify data :31 jan 2012
// --------------------------------------------------------

var inival=0; // Initialise starting element number

// Call this function to add textbox
function addTextBox()
{
var newArea = add_New_Element();
var htcontents = "<td valign='top'><input type='text' name='quan[]' style='text-align:right' onkeypress='return numbersonly(event)' /></td><td><textarea rows='1' name='desc[]' cols='48'/></textarea></td><td valign='top'><input type='text' name='price[]' style='text-align:right' onkeypress='return numbersonly(event)'/></td><td style='width:50px;padding='0' valign='top'>&nbsp;</td><td valign='top'><span style='cursor:pointer;' onclick='rem("+inival+");'><img src='img/delete.png'></span></td><br/>";
document.getElementById(newArea).innerHTML = htcontents; // You can any other elements in place of 'htcontents'
}


function add_New_Element() {
inival=inival+1; // Increment element number by 1
var ni = document.getElementById('area');
var newdiv = document.createElement('tr'); // Create dynamic element
var divIdName = 'my'+inival+'Div';
newdiv.setAttribute('id',divIdName);
ni.appendChild(newdiv);
return divIdName;
}

</script>