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>