Monday 16 December 2019

Google Calendar API Tutorial #2 | Access Different Calendars Using PHP



Download VENDOR Folder (Only for PHP version 7.2+): https://unpossiblepog.com/research-and-development/php/Vendor-Folder-For-Google-Sheet-Drive-Calendar-With-PHP-Version-7.2-And-Onward

Hello guys, this tutorial was requested by one of my viewer who asked me how to access different google calendar other than “primary”.
Before we even start, if you don’t know how to connect PHP with Google Calendar, then click the link which is at right top corner or link is given in description.
Now, according to google, “Different Calendar” doesn’t mean they display different “user interface for different calendar”, but rather they display single page and display different color box for different calendars.
So let’s create a new calendar.
Then go to code that we created in previous tutorial, as you can see, the calendar-id is set to primary which is always the first one in the list.
If we run, the events will be display from primary calendar.
So let’s create new event of newly created calendar. Make sure that it is held in future.
After that, click on three-dots of new calendar, click on “settings and sharing”, scroll down and copy calendar-id.
Paste it at the place of calendar ID.
Then, refresh it and you will get your events.
That’s only it.
Thanks for watching.

Sunday 1 December 2019

JQuery Javascript Tutorial | Convert Static HTML Table Into PHP Array | ...



index.html


    <table id="myTable" border="1" cellspacing="0" width="40%">
        <tr>
            <td> & / MODEL</td>
            <td>5kVA-48V</td>
        </tr>
        <tr>
            <td>RATED & POWER</td>
            <td>
            5000 VA / 5000 W
            </td>
        </tr>
        <tr>
            <td>INPUT</td>
        </tr>
        <tr>
            <td>Voltage</td>
            <td>
            230 VAC
            </td>
        </tr>
        <tr>
            <td>Selectable Voltage Range</td>
            <td>
            170-280 VAC (For UPS Mode); 90-280 VAC (For Appliance Mode)
            </td>
        </tr>
        <tr>
            <td>Frequency Range</td>
            <td>
            50 Hz/60 Hz (Auto sensing)
            </td>
        </tr>
        <tr>
            <td>OUTPUT</td>
        </tr>
        <tr>
            <td>AC Voltage Regulation (Batt. Mode)</td>
            <td>
            230 VAC ± 5%
            </td>
        </tr>
        <tr>
            <td>Surge Capacity</td>
            <td>
            10000 VA
            </td>
        </tr>
        <tr>
            <td>Overload Protection</td>
            <td>
            93%
            </td>
        </tr>
        <tr>
            <td>Efficiency (Peak)</td>
            <td>
            10 ms (For UPS Mode) ; 20 ms (For Appliance Mode)
            </td>
        </tr>
        <tr>
            <td>Transfer Time</td>
            <td>
            10 ms (For UPS Mode); 20 ms (For Appliance Mode)
            </td>
        </tr>
        <tr>
            <td>Waveform</td>
            <td>
            Pure Sine Wave
            </td>
        </tr>
        <tr>
            <td>BATTERY  AC CHARGER</td>
        </tr>
        <tr>
            <td>Battery Voltage</td>
            <td>
            48 VDC
            </td>
        </tr>
        <tr>
            <td>Floating Charge Voltage</td>
            <td>
            54 VDC
            </td>
        </tr>
        <tr>
            <td>Overcharge Protection</td>
            <td>
            60 VDC
            </td>
        </tr>
        <tr>
            <td>SOLAR CHARGER</td>
        </tr>
        <tr>
            <td>Number of MPPT Trackers</td>
            <td>
            1
            </td>
        </tr>
        <tr>
            <td>Maximum AC Charge Current</td>
            <td>
            60 A
            </td>
        </tr>
        <tr>
            <td>Maximum PV Array Open Circuit Voltage</td>
            <td>
            145 VDC
            </td>
        </tr>
        <tr>
            <td>MPPT Range @ Operating Voltage</td>
            <td>
            60 ~ 115 VDC
            </td>
        </tr>
        <tr>
            <td>Maximum Solar Charging Current</td>
            <td>
            80 A
            </td>
        </tr>
        <tr>
            <td>Maximum Efficiency</td>
            <td>
            98%
            </td>
        </tr>
        <tr>
            <td>Standby Power Consumption</td>
            <td>
            2 W
            </td>
        </tr>
        <tr>
            <td>Maximum PV Array Power</td>
            <td>
            4000 W
            </td>
        </tr>
        <tr>
            <td>Monitoring</td>
        </tr>
        <tr>
            <td>Monitoring Software</td>
            <td>
            Included
            </td>
        </tr>
        <tr>
            <td>Net Weight (kgs)</td>
            <td>
            5
            </td>
            <td>
            6.3
            </td>
            <td>
            8.5
            </td>
        </tr>
        <tr>
            <td>PHYSICAL</td>
        </tr>
        <tr>
            <td>Dimension, D x W x H (mm)</td>
            <td>
            120 x 295 x 468
            </td>
        </tr>
        <tr>
            <td>Net Weight (kgs)</td>
            <td>
            11
            </td>
        </tr>
        <tr>
            <td>OPERATING ENVIRONMENT</td>
        </tr>
        <tr>
            <td>Humidity</td>
            <td>
            5% to 95% Relative Humidity(Non-condensing)
            </td>
        </tr>
        <tr>
            <td>Operating Temperature</td>
            <td>
            0°C - 55°C
            </td>
        </tr>
        <tr>
            <td>Storage Temperature</td>
            <td>
            -15°C - 60°C
            </td>
        </tr>
    </table>
    <button onclick="send_values()">Export</button>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script type="text/javascript">
    function send_values()
    {
        string="";
        tr_count=0;
        $("#myTable tr").each(function()
        {

            td_count=0;
            tr_count++;

            if(tr_count>1)
            {
                string=string+',';
            }

            each_tr_length=$(this).find("td").length;
            string=string+'"tr'+tr_count+'":{"count":"'+each_tr_length+'",';
            $(this).find("td").each(function()
            {
                td_count++;
                string=string+'"td'+td_count+'":"'+($(this).html())+'"';
                if(td_count<each_tr_length)
                {
                    string=string+',';
                }
            });
            string=string+'}';
        });
        string=('{"info":[{'+string+'}]}').replace(/&amp;/g,'%26');
        alert(string);
        window.location.href="read_url.php?data="+string;
    }
</script>

read_url.php


<?php
//echo $_REQUEST['data'];
$json_arr=json_decode($_GET['data'],true);
//print_r($json_arr['info']);

foreach($json_arr['info'][0] as $key => $value) {
    for($i=1; $i <= intval($value['count']); $i++) {
        echo "</div>".$value['td'.$i]."</div>";
    }
}

?>

Description:


Hey guys, this is UNPOSSIBLE POG.
In this video, I shall explain how to use JQUERY javascript to convert static html table into Backend language.
In my case, the backend language is PHP.
The main reason to use this code is when client gives some static table which is vary large that it will take a lot of time to insert into database table one by one.
Let’s get started.
First requirement is to add ajax jquery link in code.
As you can see, I already created a sample table.
Table’s id will be “mytable”.
Lets create a script tag, and call the function onclick event of button.
Let’s verify if it is working.
Now, the main challenge is to find how many rows and columns are present it table.
Now, we are using jquery syntax to find jump to each “tr” tag.
The second task is to find how many columns are there in each row.
So type this code.
We are finding each column, then jump in each column by using each function.
Now, we are table to get each value within each column.
Now, we have to make a JSON of each value by appending a string.
We are getting tr and td count.
Lets make only two columns in second row.
We get two in second output so we are on right track.
We have to carefully make json as single mistake destroys JSON structure.
We put count of each columns in the beginning of JSON.
Let’s put that outside.
We shall separate it by commas.
Also, we have to make teach tr with unique id to avoid conflict.
Now, each tr have their own array.
Now we are going to add the data in each column.
We have completed the task of creating a JSON. Now the next task it so send those values in URL.
So for that, we shall using basic location function of javascript.
As you can see, I already created a file which decodes the JSON data.
Let’s run it.
As you can see, the data is coming.
Now lets test the code by increasing the data.
Although the task doesn’t end here. The special character called “ampersand” creates a problem while sending data.
Lets add ampersand.
You can see, ampersand is automatically converted into this, and it is creating a problem.
The solution is very easy.
We have to replace ampersand with ‘%26‘
Don’t give any quote in pattern.
And as you can see. The data is submitted.

Friday 25 October 2019

Google Calendar API Tutorial | Connect Calendar With PHP | Display And A...



Download VENDOR Folder (Only for PHP version 7.2+): https://unpossiblepog.com/research-and-development/php/Vendor-Folder-For-Google-Sheet-Drive-Calendar-With-PHP-Version-7.2-And-Onward
Watch above video for complete guidance

Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)
Enable GOOGLE CALENDAR:-
https://calendar.google.com/calendar/
Install LUBUNTU, XAMPP & SUBLIME TEXT:-
https://youtu.be/X09awd5Q8Bk
Install Composer (In windows):-
https://www.youtube.com/watch?v=BGyuKpfMB9E
Install Composer (In LINUX):-
sudo apt install composer
Connect Calendar With PHP:-
https://developers.google.com/calendar/quickstart/php
Insert Event:-
https://developers.google.com/calendar/v3/reference/events/insert
------------------------------------------------
Social Media Links :-
Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1
Facebook Page:-
https://www.facebook.com/UnpossibleNS
Twitter Account:-
https://twitter.com/UnpossiblePOG
Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------
Hey guys, this is UNPOSSIBLE POG.
In this video, I shall connect “PHP” with “Google Calendar” using “Google calendar API”.
Before we start, If you have linux, then its great, otherwise install linux in “Oracle Virtualbox”.I would prefer a debian family like Ubuntu, Lubuntu, Linux Mint, Xubuntu.
The link of “How to install composer” is in the description.
Of course you can use windows, but  when I was trying to connecting, it was vary frustrating because not only PHP wasn’t connecting but the xampp was getting corrupted when I tried to install composer.
In this video, I am using LUBUNTU, which is lightweight operating system.
For complete setup guidelines for Lubuntu and xampp, click on the right top corner.
And you must have “Google Account”
And also, google did provide some guidelines, but some of them are not properly explained or some code are not ready to go.
Let’s get started.
Open up the browser, and search for “Google Calendar quickstart php”.
Go to the link or link is in the description.
So as they say, we need, php version more than 5.4.
Now we need to install composer.
As you can see, I already installed it.
Then we need to enable “Google calendar ”. Click on the button, it will automatically enable it for us.
It may take more than one minute.
Now, open notepad, and store those values just for backup.
Although, what we actually need is “credentials.json” file, so download it.
Now go to downloaded location, create a new folder in htdocs folder inside xampp, give it any name. Then paste “credentials.json” file in it.
Now, open that folder in terminal, and paste the command that they provided. Hit ENTER.
It may take several minutes because it is downloading lot of files from google server. Have patients.
Now we are good to go.
Next is to copy the code, create a file inside “API” folder, create a new file with any random name. Paste that sample code. the close php tag.
Here, they made some code which is not ready to go. So copy that DIR line, and paste it before “credentials.json” somewhere at line 17.
Now in terminal, make sure that, we are at same location where “quickstart.php” is.
Run the file by typing command “php quickstart.php”.
Oops, I forgot to give forward slash. My bad.
Rerun it, now it asks for varification code. So copy the link above that line.
Paste it in “Browser’s URL.” Hit enter.
Sign in, it is preventing you, just click on “Advanced” then click on “ Go To quickstart(unsafe)”.
Now notice that line says “View Your Calendar”. It means we only have an access to view calendar. Allow it.
Now, they provide you the verification code, copy it, paste it for backup and paste it in “terminal”.
Now the output says, “No Upcoming event found” because we didn’t create any events yet.
So go to google, search for “google calendar”, click on this link.
You will see your calendar.
Now you notice that red line which is the current time, I shall make two events. 1 before the red line and 1 after the red line.
Now, lets rerun it.
You will see, that that it is showing the upcoming event but not past event.
Before that, we shall make run it on browser.
When, we run it on browser, it doesn’t allow you to.
It shows the error :-
“Fatal error :  Uncought Exception: This application must be run on command line”
So just comment those lines. and refresh the page.
And boom, your code is now connected with browser.
If you want all events. Then we shall first check the output of date(c).
We shall copy that and change date to 0000-01-01.
Now we are getting all results.
If you observe, thare are several attributes of each event like description, timezone etc.
So for that, there are functions available. We shall receive the description of each event by call getDescription() function.
Now lets add some events, shall we?
Open browser, search for “insert calendar event API”. Search for “PHP”.
Copy this code, and paste it within our code.
You can paste it at the end of code if you want to. But you must paste it somewhere below “events” variable.
Now, they instructed us to change the scope to CALENDAR.
So Copy-paste it above.
Now, the next instruction is incorrect. We don’t have to delete “credentials.json” file.
Open, “token.json” and remove ”.readonly“ from scope variable.
Now it is giving me the error called “insuffucientPermission”. Which is obvious.
Error goes like this:-
...............{
Fatal error: Uncaught Google_Service_Exception: { "error": { "errors": [ { "domain": "global", "reason": "insufficientPermissions", "message": "Insufficient Permission: Request had insufficient authentication scopes." } ], "code": 403, "message": "Insufficient Permission: Request had insufficient authentication scopes." } } in /opt/lampp/htdocs/api/vendor/google/apiclient/src/Google/Http/REST.php:118 Stack trace: #0 /opt/lampp/htdocs/api/vendor/google/apiclient/src/Google/Http/REST.php(94): Google_Http_REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #1 /opt/lampp/htdocs/api/vendor/google/apiclient/src/Google/Task/Runner.php(176): Google_Http_REST::doExecute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #2 /opt/lampp/htdocs/api/vendor/google/apiclient/src/Google/Http/REST.php(58): Google_Task_Runner->run() #3 /opt/lampp/htdocs/api/vendor/google/apiclient/src/Google/Client.php(842): Google_Http_ in
}.................
I shall explain how to remove it.
Now delete “token.json”. Make sure to have backup of it.
Now, lets rerun it but on terminal.
Now they are asking for verification code, “paste that link in browser”.  They are telling us that “Now you are having access such as edit, delete, add in google calendar.”
Make sure that they are checked.
Copy the verification code, and paste it in terminal.
Now it says that “event is created. But in 2015”
I shall delete it for now.
And I shall make count as 1, so that “Event will be added one time only.”
As you can, see “displaying” and “adding” events are now working.
If you are smart enough, you can figure out “how to edit or delete event” all by yourself. I trust in you. All the best.
Thanks for watching.
Don’t forget to like, share and subscribe.

Friday 11 October 2019

Xampp | Increase Maximum File Upload Limit | PHP.INI Configuration | LUB...



Hey guys, this video will be about increasing the maximum upload file limit in xampp and where to find php.ini file in LUBUNTU OS.
If you want to know how to install xampp in LUBUNTU, then click on top right bottom corner or link is given in the description.
As you know, xampp means PHP, and in PHPMYADMIN, you can see the minimum file upload “1024MB” means “1GB”. For you it could be 128mb or 5MB and we are going to increase it.
The file called “php.ini” is present in etc folder.
First make sure to have a backup of file “PHP.ini” file. Saving it on desktop.
Go to xampp folder. Right click on “ETC” folder and open it in terminal.
Type “SUDO NANO PHP.ini”. Enter the password of ROOT. The work NANO is text editor, just like “notepad” but it open within terminal.
now creaflly click “CTRL + W”, which helps you find the text within file.
Type “post_max_size”, then click on enter.
So here is the list
128M= 128 Megabyte
1G= 1 Gigabyte
I am going to increase it upto 2 GB.
Again click “CTRL + W”, then and search “upload_max_filesize”.
Increase it.
After that, click on “CTRL + X”, it will ask you to save,
First press “Y” HIT ENTER then again HIT ENTER.
Lets verify it, I shall go to phpmyadmin to check.
As you can see, the filesize increased from 1GB to 2GB.
That is how it works.
Thank you for watching.

PHP Tutorial | Easiest Way To Redirect To Last Visited Page After Login | No Session Or Database

index.php
<?php include('header.php');?>
<h1>This is the INDEX Page</h1>

-------------------
header.php
<?php
$protocol=$_SERVER['SERVER_PROTOCOL'];

if(strpos($protocol, "HTTPS"))
{
    $protocol="HTTPS://";
}
else
{
    $protocol="HTTP://";   
}
$redirect_link_var=$protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
?>
<table width="100%" border="1" cellspacing="0">
    <tr>
        <td><a href="index.php">index</a></td>
        <td><a href="login.php?page_url=<?php echo $redirect_link_var;?>">login</a></td>
        <td><a href="page1.php">page 1</a></td>
        <td><a href="page2.php">page 2</a></td>
        <td><a href="page3.php">page 3</a></td>
    </tr>
</table>

-------------------
login.php

<?php include('header.php');?>
<?php
if($_POST)
{
    if($_POST['username']=="123"&&$_POST['password']=="123")
    {
        $redirect_link=$_REQUEST['page_url'];
        if($redirect_link=="")
        {
            header("location: index.php");
        }
        else
        {
            header("location: ".$redirect_link);   
        }
    }
}
?>
<form action="" method="post">
    <input type="text" name="username">
    <br/>
    <input type="password" name="password">
    <br/>
    <input type="submit" name="" value="login">
</form>

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

page1.php
<?php include('header.php');?>
<h2>This is page 1</h2>
-------------------
page2.php
<?php include('header.php');?>
<h3>This is page 2</h3>
-------------------
page3.php
<?php include('header.php');?>
<h4>This is page 3</h4>

Monday 30 September 2019

A Trip To Hyderabad & Mallikarjuna Jyotirlinga | Part 2 | Telangana And Andhra Pradesh | Homecoming




After visiting the main place "Mallikarjuna Jyotirlinga", we packed our bags, completely exhausted and went for our first destination to go home, that is, Hyderabad. One of our friend have some friends who live in Hyderabad. We met them, and they helped us exploring the city. The main thing that I was excited about is "Chicken Biryani". After that, we went to hotel, spent night and next day, we catch train. We had fun dancing in train as we always do. Then we reach PUNE and then catch the bus to reach MUMBAI.

Monday 16 September 2019

PHP Tutorial | Navigate To Next And Previous Week & And Get Dates Within Week











Code : navigate_week.php
<center>


<a href="navigate_week_tutorial.php">Refresh</a>
<br/>
<?php
$week=0;
if(isset($_GET['week_count']))
{
$week=$_GET['week_count'];
}
else
{
$week=date('w');
}
echo "Today's Date :".date('Y-m-d'). " | Day : ".date('D');
echo "<br/>";
echo "First day of week : ".$week_first_date=date('Y-m-d',strtotime("-".(0+$week)." days"));
echo "| Day : ".date('D',strtotime($week_first_date));
echo "<br/>";
echo "Last day of week : ".$week_last_date=date('Y-m-d',strtotime("+".(6-$week)." days"));
echo "| Day : ".date('D',strtotime($week_last_date));
echo "<br/>";
$next_week_var=intval($week)-7;
$previous_week_var=intval($week)+7;
?>


<a href="navigate_week_tutorial.php?week_count=<?php echo $previous_week_var;?>"> << Previous Week</a> 

OR

<a href="navigate_week_tutorial.php?week_count=<?php echo $next_week_var;?>">Next Week >> </a>
<br/>
<?php
for($i=0;$i<=6;$i++)
{
echo $temp_date=date('Y-m-d',strtotime($week_first_date."+".$i." days"));
echo "| Day : ".date('D',strtotime($temp_date));
echo "<br/>";
}
?>
</center>

Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/



 Hello guys.
In this tutorial, we
shall discuss how to navigate to each week, how to set range of
weekdays like from monday to sunday, or sunday to saturday, or any
from and to days you want ,and also how to get days of each week.
For example, let say
the current day is 15 sept 2019, so the range will always be of 7
days. But we get days from wednesday to tuesday.
We can also navigate
to next weeks or previous weeks and get dates between them.
So lets get started.
We shall build code
from the scratch.

First we shall get today’s date and day.
Next, I am going to
add refresh link, it’s purpose will be revealed later.
New we shall find
the week-day count using this code.
By using this, we
shall get first day and last of every week.
For first day, we
are using “minus” symbol in strtotime function.
And for last day of
week, we shll use plus sign.
Let get, which day
it is.
Now we shall find
all days between two days by using for loop.

Let make it on
center.
Now we shall add
week navigation, so fot that we have to find two numbers, for next
week and last week.
For previous week,
there will be + 7.
In href, we shall
make a variable called week count. And assign value for previous and
next week.
Now, even when
clicked on link, it doesn’t do anything.
So we have to
overwrite the $week value.
Let test
it.

Acutally I made a mistake in a code.
Ok, so you just have
to add + instead of minus at “Week first date”.
Lets refresh and
test, as you can see, we are hopping on each week.
But what if, we want
start date from monday. So change, like this and as you can see, the
result is coming correctly.
You can select from
day to any day like monday, tuesday wednesday.
So actually, the
main strategy is those numbers, we have to make sure that the
addition between them should be 6.

Let change current date to
17 september.
So no matter what
your current date will be, the code will display every day of every
previous and next weeks.
The code’s link is
in the description.
Thank you for
watching, dont forget to like share and subscribe.




Friday 6 September 2019

PHP Tutorial | Display Days : Hours : Minutes : Seconds Between Two Dates


Code : 

<h1>

<center>

<?php

$current_date_time_sec=strtotime("2019-8-31 03:45:00");


$future_date_time_sec=strtotime("2019-9-3 00:00:00");


$difference=$future_date_time_sec-$current_date_time_sec;


$hours=($difference / 3600);


$minutes=($difference / 60 % 60);


$seconds=($difference % 60);


$days=($hours/24);


$hours=($hours % 24);


echo "The difference is <br/>";


if($days<0)

{

echo ceil($days). " days AND ";

}

else

{

echo floor($days). " days AND ";

}


echo    sprintf("%02d",$hours).":".sprintf("%02d",$minutes).":".sprintf("%02d",$seconds);


?>

</center>

</h1>




Hello guys.
This tutorial will be about how to get difference between two dates in days,hours,minutes,seconds format.
Lets start code with a scratch.
You have to call a function str_to_time, make sure to provide date-time format same as in the video.
This function gives the number of seconds of each date.
Now we have to calculate the diffrence.
There are formulas for calculating days, minutes, using seconds.
Make sure you type them as it is.
Now the problem is, single digit doesn’t look good, so we have to convert it using sprintf function.
This function will have two argument, 1st for formatting, and 2nd for value.
I forgot to give zero before 2.
Lets try using different numbers.
All good.
Now 49 hours means, 2 days and 1 hour extra.
So, for that, apply other formulas.
We have to overwrite the hour variable.
You see that, the days are in decimal.
So to make it easy to understand, if days are -ve, then use ceil, and if days are +ve, then use floor.
Lets, test it using different dates.
The code is in the description.
Thank you for watching, dont forget to like share and subscribe.

Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)


Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/

Friday 30 August 2019

Mysql Tutorial | Give Priority To Specific Values In Select Query Using ...



Query Examples









1) SELECT * FROM
`employee` order by FIELD(name,"steve rogers","loki")
desc
2) SELECT * FROM
`employee` order by FIELD(salary, id IN (select id from employee
where salary > 300 and salary < 800))








Hello guys.
This tutorial will
be about how to give more priority to specific values in SELECT query
of mysql database server without where clause. And how to fix the
error “subquery returns more than 1 row”. In order by field. For
example, what if you want employee should have more priority where
the salary between 300 and 700 then the rest will be displayed.
The application of
using this will be, getting data which are more related to topic like
google search.
As you can see, i
have one employee table, so instead of using where clause, I am going
to use order by Field, the FIELD is a function, the first argument
will be the calumn name that you want to be ordered, then in other
arguments, you can specify which values you specifically want, in my
case its steve and loki. Make sure to type “DESC” to make sure
that they come on top of list.
But what if you
don’t know how many data should have more priority or if the list
is too large, in that case, we shall use the subquery.
In my case, I want
to give prioritize by salary, so first argument will be salary, and
in second argument, in subquery I am going to call primary key, which
is ID, then apply the condition of salary between 300 and 800.
As you can see, it
is giving me the error that “it is returning more than one row ”
which is obvious. So to fix it, just apply condition “id in”
before subquery.
In result, you can
see that all the data is coming, but employee between salary 300 and
700 have more priority.
Thank you for
watching, dont forget to like share and subscribe.

Saturday 24 August 2019

A Trip To Hyderabad & Mallikarjuna Jyotirlinga | Telangana And Andhra Pr...



Please avoid or flag spams/hateful comments. And do not spam. Enjoy :)

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/

The trip was a visit to our 4th jyotirlinga out of the 12. In the morning, we thought everything will go smoothly but suddenly we got a message the train from mumbai was cancelled and now we had to go to PUNE to catch that train. So somehow made it vary early. Sadly some people who were already in train didn't know that train will not go to mumbai. We hoped that they reached home safely. The train was empty with few people. In the morning, we realized that we are already outside Maharashtra state which was TELANGANA. After we reached to hyderabad, we quickly catch the BUS to andhra pradesh. Our destination was mallikarjuna Srisailam. Between that BUS journey, we found that there is one DAM near the road. We decided to stop there when we return home.

Thursday 15 August 2019

Sublime Text 3 Bug | Solution & Avoidance Of Not Highlighting PHP Syntax











Hello guys, this is
unpossible pog here.
Today, I shall talk
about the PHP code not getting highlighted while using SUBLIME text.
I am using the
SUBLIME version 3.2.1.
As you can see, the
PHP code is not highlighted means it is in plain white color.
So I shall tell you
the solution as well as how to avoid PHP not getting highlighted.
The solution is vary
easy.
You just have to
close it and reopen it. Thats it and your PHP code will be
highlighted.
Although how to
avoid it is also vary easy.
Usually when you
copy-paste the code, it creates a problem as you can see.
So to avoid that,
first create empty “untitled” file, paste the code, then save it.
With that, sublime
recognizes PHP code and highlights it automatically.
Thank you for
watching, dont forget to like share and subscribe.

Sunday 4 August 2019

AngularJS Tutorial | Easiest Way To Upload Multiple Files



index.php



<!DOCTYPE html>  

 <html>  

      <head>  

           <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

           <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.8/angular.min.js"></script>

      </head>  

      <body style="padding-top: 30px;">  

      <center><h2>Angular JS 1.7 <br> <b>Easiest Way To Upload Multiple Files</b></h2></center>

           <div style="padding-top: 30px;" class="container" ng-app="myapp" ng-controller="myController" ng-init="select()">  

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

                     <input type="file" file-input="files" class="form-control" multiple/>  

                </div>  

                <div class="col-md-12" style="padding-top: 10px;">  

                     <button class="btn btn-success form-control" ng-click="upload()">Upload</button>  

                </div>  

                 

           </div>  

      </body>  

 </html>  

 <script>  

 var app = angular.module("myapp", []);  

 app.directive("fileInput", function($parse){  

      return{  

           link: function($scope, element, attrs){  

                element.on("change", function(event){  

                     var files = event.target.files;  

                     $parse(attrs.fileInput).assign($scope, element[0].files);  

                     $scope.$apply();  

                });  

           }  

      }  

 });  

 app.controller("myController", function($scope, $http){  

      $scope.upload = function(){  

           var form_data = new FormData();  

           var count=0;

           angular.forEach($scope.files, function(file){  

                form_data.append('file'+count, file);  

                count++;

           }); 

           form_data.append('count_of_files', count);   

           $http.post('upload_file.php', form_data,

           {  

                transformRequest: angular.identity,  

                headers: {'Content-Type': undefined,'Process-Data': false}  

           }).then(function(response){  

                alert(response.data);  

           });  

      }  

 });  

 </script> 
upload_file.php


<?php

for($i=0;$i<intval($_POST['count_of_files']);$i++)

{

if($_FILES['file'.$i]['name']!="" )

{

move_uploaded_file($_FILES['file'.$i]['tmp_name'], ''.$_FILES['file'.$i]['name']) or die ('cannot upload');   

}

}



?>








Hello guys, this is
unpossible pog here.
Today, I shall show
you the easiest way to upload mutiple files using ANGULAR JS 1.7 &
PHP.
Before we that, if
you are linux user, then make sure that you have the permission to
upload anything.
Now if you see the
current code, it lets you upload the file one at a time. And we are
changing it to upload multiple files.
I created one PHP
file called “upload_file.php” to perform upload operation.
The strategy is to
give each file a specific name.
So I shall create a
count variable, within the loop. I shall increase it by one.
Then I shall create
the “POST VARIABLE NAME” called “count_of_files” and append
it in form.
In php code, I shall
echo it.
Make sure to add
multiple attribute on file input type.
Now it will show me
the count of files selected for uploading.
Here we go.
Now we have to give
each file a specific name, so append count number after each file.
With that, each file
will have it’s own unique name.
In PHP code, we
create a for loop, and limit it upto that variable.
Now, we have to call
each file by its unique name. So, append variable I after each file.
Lets test, we shall
select 3 files, and click on “UPLOAD”. And those files are
uploaded in folder.
The code is in the
description.
Thank you for
watching, dont forget to like share and subscribe.

Saturday 27 July 2019

JAVA Tutorial | How To Convert Array Into String Without Loops | Quickes...





class array_to_string

{

public static void main(String ar[])

{

String output="";

String arr[]={"Captain","America","lifts","the","HAMMER"};

/*

for(int i=0;i<arr.length;i++)

{

output = output + arr[i] + ",";

}

*/

output=String.join(" ",arr);

System.out.println(output);

}

}


Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/

Hello guys, this is unpossible pog here.
Today, I shall show you the easiest and convenient way to convert array into string in JAVA.
So, generally we use loops to convert but main problem is that it will take more time to execute for large array.
And secondly, even if we do that, we see some unwanted characters either at the begenning or ending of string.
You can see that, the COMMA is bothering me.
So, java has a function called join with two arguments. 1st is the glue and second will be the array.
With that, the values are automatically connected by glue and no extra COMMAS.
The code is in the description.
Thank you for watching, dont forget to like share and subscribe.

The Grishneshwar Temple

Sunday 30 June 2019

Easiest Way To Get Hash Color Code Of Image Without Any Photo Editing So...











Hello guys, this is
unpossible pog here.
Today, I shall show
you the easitest way to get hash code of any image stored in your
computer without any photo editing software.

For that you only
need google chrome.
As you can see, I
have one image on desktop, and what I shall do is drag-and-drop it on
google chrome.
Now right click and
select on “INCEPT”.
Change the dock
location if you want to.

After that there is a background code
in styles tab, click on color, and select color picker, make sure
that it is marked in blue color.
Then move mouse
cursor at the image pixel, and do left click on it.
You will see, the
hash color code on image here.
That it guys.
Thank you for
watching, dont forget to like share and subscribe.

Sunday 16 June 2019

Easiest Way To Create Realtime Live Notification Count Like Facebook | PHP | AJAX | JAVASCRIPT




Code:-
notification.php

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<table width="100%" style="background-color: #0066ff;color: white;">
 <tr width="75%">
  <td>
   <h2>Welcome to facebook</h2>
  </td>
  <td width="15%">
   <i class="fa fa-bell" aria-hidden="true" id="noti_number"></i>
  </td>
 </tr>
</table>
<script type="text/javascript">
 function loadDoc() {
  

  setInterval(function(){

   var xhttp = new XMLHttpRequest();
   xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
     document.getElementById("noti_number").innerHTML = this.responseText;
    }
   };
   xhttp.open("GET", "data.php", true);
   xhttp.send();

  },1000);


 }
 loadDoc();
</script>


data.php

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);

$sql = "SELECT * FROM notification_data";
$result = $conn->query($sql);

echo $result->num_rows;
/*
if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo "id: " . $row["id"]. " - Notification: " . $row["description"];
    }
} else {
    echo "0 results";
}
*/
$conn->close();
?>

Hello guys, this is unpossible pog here.
Today, I shall show you the easitest way to display live notification count without refreshing the page like facebook.
As soon as we insert data, the notification count changes which means we no longer have to refresh the page.
I am using the combination of php, javascript and basic ajax.
Let say, if someone likes your photo on facebook, it get stored in database. So in short we have to fetch count of data from database table.
Lets get started.
Here I created one sample page which shows static number of notification so we have to make it dynamic and live.
I created one table in database which represents your notification.
I created one file called “DATA.PHP ” which displays the notification.
But we only want the count so echo the count only.
Now the next task is to access that file in our design page using ajax.
So, create one javascript function and go to google.
Search for ajax code. Go inside w3school site
Copy paste the ajax code.
After the function end, type the function name with rounded brackets and semicolan.
Give an ID to division or any tag that you want.
And copy that same ID in ajax code.
Type the page name here which is connected to database.
Let refresh. And you will see that it is showing the notification count.
Now you have to add function called “SET INTERVAL”, to constantly refresh that ID afer 1 second. Create a function and cut-paste the code inside the curly brackets.
After that we no longer have to refresh page to change notification count.
Lets add some data in table.
Keep looking at notification count.
As soon as we insert data, the notification count changes.
You can give href to that icon to redirect to notification page if you want to.
Thats all for now.
The code is in the description.
Thank you for watching, dont forget to like share and subscribe.

Sunday 9 June 2019

LUBUNTU : Install, Launch & Uninstall Xampp | Install Sublime Text | Mak...













Hello guys, this is
unpossible pog here. I am using LUBUNTU Linux OS and today I shall
show you how you can install xampp, how to execute it,how to install
sublime text software. how to make HTDOCS folder editable, run
program, and lastly how to uninstall xampp.

Now, there are
combined into one video and are shown in specific timeline.
You can jump to
those time to get you requirment or you can watch the full video.
So in the first part
which is how to install XAMPP, open the browser and search for “XAMPP
LINUX” and go for the linux. Mine is 64 bit system, so I shall
install 64 but if you have 32 bit OS then you must download 32 bit
version file. The file has the extension of “(DOT) RUN” which is
similar to “EXE” extension of Windows executable files.
I already downloaded
it, so I go to “DOWNLOADS” folder.
You can see the
file, now open the “MENU”, go to “SYSTEM TOOLS” and select
“LX TERMINAL”.

Now type “CD” command to go inside
“DOWNLOADS” folder. Type “DIR” command to find your file. Now
you have to make sure that it is executable file so type command
“CHMOD 755 ” then the file name.
Then, to run the
file, use “SUDO” means “Super User Do”, (“DOT”), then
(“FORWARD SLASH”)

, then filename. Make sure to check the
spelling. Type SUPER USER’s password.

By default it will be
installed in OPT(“SLASH”)LAMP folder.
We shall now LAUNCH
XAMPP right now, becuase lot of people don’t know how to run file,
so we shall uncheck it and finish it.
Now the PART 2 is
started where we shall work on executing the XAMPP.

Now open
file system. By default, you shall this, where you can not find the
folder where the xampp installed.
So, click on places,
and select “Directory tree”. You can see the (“SLASH”), click
on it. You can see OPT folder, and inside it , there is “LAMPP”
folder. Now there is one file called “manager-linux.run”

Now
, open new terminal, the type “CD” the (“SLASH”).

Now
you entered into file system, change directory to OPT, then LAMPP.
Now to run “manager
linux” file, type “SUDO then (DOT) then (SHASH) then
manager-linux” file.

In “MANAGE” server tab, start all
services.

Now you can open browser , and type IP address of
xampp, which is “127.0.0.1”
you will se the
dashboard.
In part 3, I shll
show you how to install sublime text 3 which is used for writing a
program. Its just my suggestion to use sublime because I personally
like it.
So to do that, go to
web browser, search for “SUBLIME TEXT 3 LINUX”, click on link
based on you OS but version. Mine is 64.

After downloading it,
right click on it, and “EXTRACT HERE”. After that, the folder
will appear, go inside it, and I think double click on
“SUBLIME(SPACE)TEXT”.

Sorry, my bad, click on
“SUBLIME(UNDERSCORE)TEXT” and execute it. And there you go.

In
part 4, we shall find how to make “HTDOCS” file editable.

So,
what do I mean by that?

So, In linux, by default, you don’t
have any permission to make any changes if you are normal user.

You
only have to change permission of HTDOCS, because it change
permission OPT folder, then whole XAMPP may stop working.
In order to get
permission of HTDOCS, open the terminal, go to file system, by
pressing this command, go inside OPT and LAMPP folder, type “SUDO
then CHOWN” then your username, which in my case is SANKET then
type the folder name which is “HTDOCS”
type, superuser’s
password.
Now go inside HTDOCS
folder, and try to create folder. Paste the index file inside new
folder, then go back.
Now open the sublime
text, “DRAG AND DROP ” the new folder in sublime text’s project
list,
edit index.php file.
Now to run xampp,
follow the steps and start all services.

Now, open the browser,
type IP address of XAMPP, then give (“SLASH”), then the folder
name that we have created which is NEW.
In part 5, incase if
you want to install XAMPP.
Go to lampp folder,
and type, SUDO (DOT), then SLASH, then uninstall and hit ENTER.
If you have anything
to ask, type in comments, below, I shall try to give answers.

Thank
you for watching, dont forget to like share and subscribe.