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/