Friday, June 27, 2025

Count days between two dates

 Here I am explaining code for count days between two dates.





<!DOCTYPE html>


<html lang="en">

<head>

<meta charset="UTF-8">

<title>Date Difference - Years, Months, Days</title>

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">

</head>

<body class="p-4">




<div class="container">

<h3 class="mb-4">વાદગ્રસ્ત હુકમ તારીખ અને દાખલ તારીખ : વર્ષો, મહિનાઓ અને દિવસોની ગણતરી કરો</h3>

<div class="row mb-3">

<div class="col-md-6">

<label for="date1" class="form-label">વાદગ્રસ્ત હુકમ તારીખ (dd/mm/yyyy)</label>

<input type="text" id="date1" class="form-control" placeholder="dd/mm/yyyy">

</div>




<div class="col-md-6">

<label for="date2" class="form-label">દાખલ તારીખ (default: today)</label>

<input type="date" id="date2" class="form-control">

</div>

</div>




<div id="reultdiv"></div>

</div>




<script>

document.getElementById('date2').valueAsDate = new Date();




document.getElementById('date1').addEventListener('change', calculate);

document.getElementById('date2').addEventListener('change', calculate);




function calculate() {

document.getElementById("reultdiv").innerHTML = '';




const date1Str = document.getElementById('date1').value;

const date2Str = document.getElementById('date2').value;




const parts = date1Str.split('/');

if (parts.length !== 3) return;




const d1 = new Date(`${parts[2]}-${parts[1]}-${parts[0]}`);

const d2 = new Date(date2Str);

if (isNaN(d1.getTime()) || isNaN(d2.getTime())) return;




let output = '';




// Helper function to calculate and return HTML

function getAlertHTML(label, className, from, to) {

let totalDays = Math.floor((to - from) / (1000 * 60 * 60 * 24));

if (totalDays < 0) return ''; // skip if invalid range




let years = to.getFullYear() - from.getFullYear();

let months = to.getMonth() - from.getMonth();

let days = to.getDate() - from.getDate();




if (days < 0) {

months--;

let temp = new Date(to.getFullYear(), to.getMonth(), 0);

days += temp.getDate();

}




if (months < 0) {

years--;

months += 12;

}




return `

<div class="alert ${className}" role="alert">

<strong>${label}</strong><br>

🗓 <strong>કુલ દિવસો:</strong> ${totalDays} દિવસ<br>

📅 <strong>અવધિ:</strong> ${years} વર્ષ, ${months} મહિના, ${days} દિવસ

</div>

`;

}




// 🔹 Primary calculation

if (d1 <= d2) {

output += getAlertHTML("પ્રાથમિક ગણતરી", "alert-primary", d1, d2);

}




// 🔹 30 days check

let d30 = new Date(d2);

d30.setDate(d30.getDate() - 30);

if (d1 <= d30) {

output += getAlertHTML("30 દિવસ પહેલાની ગણતરી", "alert-info", d1, d30);

}




// 🔹 60 days check

let d60 = new Date(d2);

d60.setDate(d60.getDate() - 60);

if (d1 <= d60) {

output += getAlertHTML("60 દિવસ પહેલાની ગણતરી", "alert-warning", d1, d60);

}




// 🔹 90 days check

let d90 = new Date(d2);

d90.setDate(d90.getDate() - 90);

if (d1 <= d90) {

output += getAlertHTML("90 દિવસ પહેલાની ગણતરી", "alert-danger", d1, d90);

}




document.getElementById("reultdiv").innerHTML = output;

}

</script>




</body>

</html>

mysqli database query for count views, join and select some rows

 Here I am giving some useful mysql queries. If you check it, you will understand, which query is suitable for your project.

function getChatUserNames(){

global $db_conx;

$sql = "SELECT 

    c1.fname AS username_first_name,

    c1.mname AS username_m_name,

    c1.lname AS username_last_name,

    c1.custid AS uchatid,

    c1.uid,

    GROUP_CONCAT(DISTINCT CONCAT(c2.custid, ' - ', c2.fname, ' ', c2.lname) SEPARATOR '<br> ') AS chat_with_list

FROM 

    candidate c1

LEFT JOIN 

    (

        SELECT from_user_id AS user_id, to_user_id AS chat_with_user

        FROM chat_message

        UNION

        SELECT to_user_id AS user_id, from_user_id AS chat_with_user

        FROM chat_message

    ) AS cm_combined

    ON c1.custid = cm_combined.user_id

LEFT JOIN 

    candidate c2 ON c2.custid = cm_combined.chat_with_user

GROUP BY 

    c1.custid

";

$select = mysqli_query($db_conx,$sql);

while($row = mysqli_fetch_assoc($select)){

$ret[] = $row;

}

return $ret;

}


function getAllChatDataAdmin($user1, $user2){ 

global $db_conx; 

$ret = array();


//check block

$sql = "SELECT id FROM block_table WHERE user_id = '".$user1."' AND blocked_user_id = '". $user2."'  ";

    $select = mysqli_query($db_conx, $sql);

    $blockCheck = (mysqli_num_rows($select) == 0) ? '0' : '1';


    //get chat data

$query = "

    SELECT a.fname as from_user_name, b.fname as to_user_name, cm.chat_message, cm.timestamp,  cm.to_user_id, cm.from_user_id, cm.status

    FROM chat_message cm

    INNER JOIN candidate a

    ON cm.from_user_id = a.custid

    INNER JOIN candidate b

    ON cm.to_user_id = b.custid

    WHERE (cm.from_user_id = $user2 AND cm.to_user_id = $user1 ) 

    OR (cm.from_user_id = $user1 AND cm.to_user_id = $user2 )

    ";


    $chatdata = mysqli_query($db_conx,$query);

    while($row = mysqli_fetch_assoc($chatdata)){

    //$row['blockCheck'] = $blockCheck; //insert blockcheck variable

$ret[] = $row;

}


return $ret;

}

//15-06-2025

function getInterestMsgText($tocid){

global $db_conx;

$fromid = $_SESSION['cid'];

$sql = "SELECT * FROM interestmsg WHERE toid = '".$tocid."' AND fromid = '".$fromid."' AND status = 1 ";

$result = mysqli_query($db_conx, $sql);

return $row = mysqli_fetch_assoc($result);

}

function getInterestMsgs(){

global $db_conx;

$tocid = $_SESSION['cid'];

$sql = "SELECT i.*, c.uid as cuid, c.fname, c.lname 

FROM interestmsg i

LEFT JOIN candidate c On i.fromid = c.custid

WHERE i.toid = '".$tocid."' AND i.status = 1 

ORDER BY i.updateddate ASC";

$select = mysqli_query($db_conx, $sql);

while($row = mysqli_fetch_assoc($select)){

$ret[] = $row;

}

return $ret;

}

function sentInterestMsgs(){

global $db_conx;

$fromid = $_SESSION['cid'];

$sql = "SELECT i.*, c.uid as cuid, c.fname, c.lname 

FROM interestmsg i

LEFT JOIN candidate c On i.toid = c.custid

WHERE i.fromid = '".$fromid."' AND i.status = 1 

ORDER BY i.updateddate ASC";

$select = mysqli_query($db_conx, $sql);

while($row = mysqli_fetch_assoc($select)){

$ret[] = $row;

}

return $ret;

}


Thursday, February 1, 2024

Select and Insert value from dropdown multiple, write and insert multiple values

 Hello. 

Today I want to show you how to select values from dropdown, Write or insert values from dropdown and save to database and manage it.




DB table name : maternal_disease

fields: mdid, cid, shortname, status, display, createdby, createdate, updatedby, updatedate

main php file code : 

<div class="col-sm-4">
                                        <input type="hidden" name="jobskillarray" id="jobskillarray" value="">
                                        <p id="jobskillmsg"></p>
                                        <div id="servicesList2" class="servicesList2"> </div>
                                        <input type="text" name="tag_name2" id="tag_name2" placeholder="Required Skills" list="skilllist2">
                                         
                                        <button type="button" class="btn btn-primary" id="addSkillBtn2">Add This Disease</button>
                                        <datalist id="skilllist2">
                                          <?php foreach ($maternalDiseaseList as $tag) { ?>
                                               <option ><?php echo $tag['shortname'] ?></option>
                                          <?php } ?>
                                        </datalist>
                                        
                                    </div>
<script type="text/javascript">
        $(document).ready(function() {
        var quotations = [];
        var quotations_id = [];
        $('#addSkillBtn2').click(function(e) {
          //debugger;
          var len = quotations_id.length;
          $("#jobskillmsg").html('');
          if (len < 15)
          {
              let tag_name2 = $('#tag_name2').val();
              let tagname2 = tag_name2.slice(0, 100);
              $("#skillMsg").html('');
              console.log(quotations);
              //console.log(quotations_id);
              //debugger
              var data = {};
              if ( tagname2.length >= 2 ){
                //if ($.inArray(tagname2, quotations) == 0) { 
                if ($.inArray(tagname2, quotations) >= 0) { 
                    console.log(quotations);
                } 
                else {
                  //console.log(quotations);
                  //console.log(quotations_id);
                  //debugger;
                  $.ajax({
                        url: 'ajax.php',
                        type: 'POST',
                        dataType: 'json',
                        data: {set_maternal_disease: tagname2},
                        //processData: false,
                        //contentType: false,
                        beforeSend: function(){
                              $('#mydiv').show();
                            },
                        success: function(response) {
                          $('#mydiv').hide();
                          //console.log(quotations);
                          //console.log(quotations_id);
                          //debugger;
                            if (response.message == 'success') {
                               var itemname = response.data.name;
                                var itemid = response.data.id;
                                    //console.log('Value Not exists');
                                    quotations.push(itemname);
                                    quotations_id.push(itemid);
                                    var item = document.createElement("p");
                                    var skillli = '<span class="skillable" data-value="'+response.data.id+'" data-name="'+response.data.name+'" id="js_'+response.data.id+'" ><label for="">'+response.data.name+'</label><i title="delete this skill" id="icon-minus2" class="red right icon-minus-sign"> x </i></span>';
                                    item.innerHTML = skillli;
                                    document.getElementsByClassName("servicesList2")[0].append(item);
                                    $('#tag_name2').val('');
                                  //console.log(quotations);console.log(quotations_id);
                                  $('#jobskillarray').val(quotations_id);
                               
                            } else if (response.message == 'duplicate') {
                              // setTimeout(function() {
                              //     $("#skillMsgDuplicate").hide('blind', {}, 500)
                              // }, 5000);
                               $("#skillMsg").html("<div class='col-md-12'><div class='alert alert-warning'><strong>Sorry! </strong> Duplicate skill cannot be added. </div> </div>");
                            } else if (response.message == 'limit') {
                              // setTimeout(function() {
                              //     $("#skillMsgLimit").hide('blind', {}, 500)
                              // }, 5000);
                              $("#skillMsg").html("<div class='col-md-12'><div class='alert alert-danger'><strong>Sorry! </strong> Maximum 5 skills are allowed. </div> </div>");
                            } else {
                              alert('Error! Try again or refresh page.');
                            }
                        },
                        error: function() {
                          $('#mydiv').hide();
                            alert('Error occurred while adding the skill.');
                        }
                  });
                  return false; 
                  } //end if check value exist
              }
          } 
          else
          { 
            $("#jobskillmsg").html("<div class='col-md-12'><div class='alert alert-danger'><strong>Sorry! </strong> Maximum 15 Disease are allowed. </div> </div>");
          }
          console.log(quotations);
          console.log(quotations_id);
        });
        //end skill to post ajax
        //remove jobpost skill by modal
        $(document).on('click','#icon-minus2',
        function() 
        {
          var y = quotations_id;
          //if (confirm("Are you sure?")) {
            var $list =  $("#servicesList");
            listValue = $(this).parent().data('value');
            listName = $(this).parent().data('name');
            //alert(listValue);
            if (listValue !== '') {
              $("p span#js_"+listValue).remove();
              quotations_id = jQuery.grep(quotations_id, function(value) {
                        return value != listValue;
                      });
              $('#jobskillarray').val(quotations_id);
              quotations = jQuery.grep(quotations, function(value) {
                        return value != listName;
                      });
              //console.log(quotations_id);
              //console.log(quotations);
            }
              
          //}         
        });
        //end
        });
    </script>


ajax.php

//display maternal disease
if(isset($_POST['set_maternal_disease'])){
    $id_edit = string_sanitize(trim($_POST['set_maternal_disease']));
    
    $userid = $_SESSION['userid'];
    $cid = $_SESSION['cid'];
    $createddate = date("Y-m-d H:i:s");
    $disease = mb_substr($id_edit, 0, 100);
    $sql = "SELECT shortname, mdid FROM `maternal_disease` WHERE `shortname` = '".$disease."' AND `cid` = '".$cid."' AND `status` = '1' AND `display` = '1' ";
    $myquery = mysqli_query($db_conx, $sql);
    if(mysqli_num_rows($myquery) == 1)
    {
        $row = mysqli_fetch_assoc($myquery);
        $mdid = $row['mdid'];
        $shortname = $row['shortname'];
    } elseif (mysqli_num_rows($myquery) == 0) {
        //insert data
        $sql = "INSERT INTO `maternal_disease` (`cid`, `shortname`, `createdby`, `createddate`) VALUES ('".$cid."', '".$disease."', '".$userid."', '".$createddate."')";
        $insertDisease = mysqli_query($db_conx, $sql);
        if ($insertDisease === TRUE){
            $mdid = mysqli_insert_id($db_conx);
            $shortname = $disease;
        }
    } else {
    }
    $responseData = [
                    'message' => 'success',
                    'data' => ['name'=> $shortname, 
                                'id' => $mdid
                                ],
                ];
    echo json_encode($responseData);
}

Monday, January 29, 2024

God mode in windows system and its details

Hello.

Today I am going to show you GOD Mode in windows operating system. 

What Is the "God Mode" Folder in Windows and How Do I Enable It?

Here are the categories of tools you'll find in God Mode:

  • Administrative Tools
  • AutoPlay
  • Backup and Restore
  • Color Management
  • Credential Manager
  • Date and Time
  • Devices and Printers
  • Ease of Access Center
  • File Explorer Options
  • File History
  • Fonts
  • Indexing Options
  • Infrared
  • Internet Options
  • Keyboard
  • Mouse
  • Network and Sharing Center
  • Pen and Touch
  • Phone and Modem
  • Power Options
  • Programs and Features
  • Region
  • RemoteApp and Desktop Connections
  • Security and Maintenance
  • Sound
  • Speech Recognition
  • Storage Spaces
  • Sync Center
  • System
  • Tablet PC Settings
  • Taskbar and Navigation
  • Troubleshooting
  • User Accounts
  • Windows Defender Firewall
  • Windows Mobility Center
  • Work Folders

Windows 10 God Mode clearly displays the control panel settings in a list and simplifies the access via a central desktop shortcut. We explain how to activate Windows God Mode and what you can achieve with it.




  1. Create a new folder on your desktop. To do this, right-click an empty area of the desktop, hover over New, and then choose Folder.
  2. Name the folder GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}. If you've already created it with a different name, right-click the folder and choose Rename to change it.
  3. Once you hit Enter after changing the name, that name will disappear, and the icon should change into a Control Panel icon.
  4. You can now open the folder to access all the settings inside. You'll find settings for everything from AutoPlay, user accounts, disk optimization, and so on. There are a total of 201 items, but that could vary depending on what version of Windows you're running.
  5. Because it's a standard folder, you can also easily copy settings shortcuts directly onto your desktop for even quicker access. Simply drag and drop the setting you want, and it'll be accessible directly on the desktop.
Note:
You want to access the God Mode only once and without a desktop shortcut? Then just press the shortcut “Windows + R”, type shell:::{ED7BA470-8E54-465E-825C-99712043E01C} in the Run dialog and press “Enter” to bring up the God Mode menu.


Saturday, January 13, 2024

How to data scrap from other website

 Hello.

Today I am going to explain how to scrap data from other website. 

Web scraping requires careful consideration and adherence to ethical and legal standards. Before proceeding, ensure that you have the right to access and scrape the content, according to the website's terms of service.



Suppose we have one website and we want to copy some of its div data.


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Scraping Example</title>
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
</head>
<body>
<div id="output"></div>
<script>
$(document).ready(function() {
// Set the URL of the target website
var url = 'https://www.portotheme.com/wordpress/porto_landing/';
// Make an AJAX request to fetch the HTML content
$.get(url, function(data) {
// Create a jQuery object from the HTML data
var $html = $(data);
// Use jQuery to select the desired div
var $targetDiv = $html.find('.row.sample-item-list.sample-item-list-loaded.sort-destination');
// Process each item within the div
$targetDiv.find('div.col-sm-6.col-lg-4.col-xxl-3').each(function() {
// Extract data for each item
var title = $(this).find('h3').text();
var link = $(this).find('a').attr('href');
// Get the inline style of the span.sample-item element
var inlineStyle = $(this).find('span.sample-item').attr('style') || '';
// Retrieve data-oi value
var dataOiValue = $(this).find('.sample-item').data('oi');
var fileName = dataOiValue.split('/').pop();
// Display the data in the output div
$('#output').append('<p>Title: ' + title + ', Link: ' + link + ' , filename:'+fileName+'</p>');
});
});
});
</script>
</body>
</html>

Saturday, December 2, 2023

Wordpress theme add css js files right method

Hello

Today I am going to explain how to add css and js files in functions.php in wordpress theme. I was face so much issues when add css and js files. Theme is not display properly as in html view. I saw that I made mistake in include js files. My way is not right. So here I saw you the correct way.

All files are in "assets" folder.

functions.php

function load_stylesheets(){

$theme_version = wp_get_theme()->get( 'Version' );

wp_enqueue_style('bootstrap', get_template_directory_uri().'/assets/vendors/bootstrap/css/bootstrap.min.css', array(), $theme_version, false);

wp_enqueue_style('fontawesome', get_template_directory_uri().'/assets/vendors/fontawesome/css/all.min.css', array(), $theme_version, false);

wp_enqueue_style('tinyslider', get_template_directory_uri().'/assets/vendors/tiny-slider/dist/tiny-slider.css', array(), $theme_version, false);

wp_enqueue_style('owlcarousel1', get_template_directory_uri().'/assets/vendors/owl-carousel/owl.carousel.min.css', array(), $theme_version, false);

wp_enqueue_style('owlcarousel2', get_template_directory_uri().'/assets/vendors/owl-carousel/owl.theme.default.min.css', array(), $theme_version, false);

wp_enqueue_style('animate', get_template_directory_uri().'/assets/vendors/animate/animate.min.css', array(), $theme_version, false);

wp_enqueue_style('iconstyle', get_template_directory_uri().'/assets/vendors/paroti-icons/style.css', array(), $theme_version, false);

wp_enqueue_style('magnific', get_template_directory_uri().'/assets/vendors/jquery-magnific-popup/jquery.magnific-popup.css', array(), $theme_version, false);

wp_enqueue_style('youtube', get_template_directory_uri().'/assets/vendors/youtube-popup/youtube-popup.css', array(), $theme_version, false);

wp_enqueue_style('pstyle', get_template_directory_uri().'/assets/css/paroti.css', array(), $theme_version, false);

wp_enqueue_style('customcss', get_template_directory_uri().'/assets/css/custom.css', array(), $theme_version, false);


//js files

wp_register_script('jquery',get_template_directory_uri().'/assets/vendors/jquery/jquery-3.6.1.min.js',array('jquery'), $theme_version, true);

wp_enqueue_script('jquery');


wp_register_script('bootstrap',get_template_directory_uri().'/assets/vendors/bootstrap/js/bootstrap.bundle.min.js',array('jquery'), $theme_version, true);

wp_enqueue_script('bootstrap');


wp_register_script('tinislider',get_template_directory_uri().'/assets/vendors/tiny-slider/dist/min/tiny-slider.js',array('jquery'), $theme_version, true);

wp_enqueue_script('tinislider');


wp_register_script('validatefile',get_template_directory_uri().'/assets/vendors/jquery-validation/jquery.validate.min.js',array('jquery'), $theme_version, true);

wp_enqueue_script('validatefile');


wp_register_script('wowjs',get_template_directory_uri().'/assets/vendors/wow/wow.js',array('jquery'), $theme_version, true);

wp_enqueue_script('wowjs');


wp_register_script('ajaxchimp',get_template_directory_uri().'/assets/vendors/jquery-ajaxchimp/jquery.ajaxchimp.min.js',array('jquery'), $theme_version, true);

wp_enqueue_script('ajaxchimp');


wp_register_script('jqueryappear',get_template_directory_uri().'/assets/vendors/jquery-appear/jquery.appear.min.js',array('jquery'), $theme_version, true);

wp_enqueue_script('jqueryappear');


wp_register_script('carrousalmin',get_template_directory_uri().'/assets/vendors/owl-carousel/owl.carousel.min.js',array('jquery'), $theme_version, true);

wp_enqueue_script('carrousalmin');


wp_register_script('magnificpopup',get_template_directory_uri().'/assets/vendors/jquery-magnific-popup/jquery.magnific-popup.min.js',array('jquery'), $theme_version, true);

wp_enqueue_script('magnificpopup');


wp_register_script('youtubejquery',get_template_directory_uri().'/assets/vendors/youtube-popup/youtube-popup.jquery.js',array('jquery'), $theme_version, true);

wp_enqueue_script('youtubejquery');


wp_register_script('mainjsfile',get_template_directory_uri().'/assets/js/paroti.js',array('jquery'), $theme_version, true);

wp_enqueue_script('mainjsfile');


wp_register_script('customjs',get_template_directory_uri().'/assets/js/customjs.js',array('jquery'), $theme_version, true);

wp_enqueue_script('customjs');

}

add_action('wp_enqueue_scripts','load_stylesheets');

Thursday, August 24, 2023

Sorting numbers without using inbuilt function

 $result = ['9','2','5','4','3','7'];

for ($i = 0; $i < count($result) - 1; $i++) {

  for ($j = $i + 1; $j < count($result); $j++) {

    if ($result[$i] > $result[$j]) {

      $temp = $result[$i];

      $result[$i] = $result[$j];

      $result[$j] = $temp;

    }

  }

}


echo "<pre>";print_r($result);echo "</pre>";

OUTPUT:

Array
(
    [0] => 2
    [1] => 3
    [2] => 4
    [3] => 5
    [4] => 7
    [5] => 9
)