Find next Monday date in PHP

0
COM
<?php
$day = date('d');
$month = date('m');
$year = date('Y');
$nextMonday = date("Y, m, d",strtotime('next Monday',mktime(0,0,0,$month,$day,$year)));
echo $nextMonday;
?>

Generate random numbers in PHP

0
COM
There are several ways of generating random numbers in PHP. We can use a rand() function which takes two parameters(optional) to generate random numbers. But there is one more function which is more efficient mt_rand() which also takes two optional parameters, minimum and maximum value. I am going to generate some random numbers using mt_rand() function.
<?php
//Generating 10 random numbers
for($i = 0; $i < 10; $i++)
{
   //Generates random number between 0 and 50
   echo mt_rand(0, 50) . '---';
}
?>
Here is the output of the above code:


Read XML file using PHP

0
COM
Reading XML file in PHP is as easy as copy-paste. We can read an XML file using simplexml_load_file() function which takes XML filename as a parameter:

simplexml_load_file($filename);

Let's read an XML file containing song list:



Now the PHP:


?php  
$filename = "sample.xml";
$xml = simplexml_load_file($filename);
?>

Now you access any tag in the XML using the variable $xml.
Let's see how it works: 





Now let's what it did for us:


You can also access the attributes like this: 



which will look like this:


And in the end if you want to read the whole XML, then abviously loop will be used, here is the code:



And here is the output: 




Hope this tutorial will be helpful to you...

Styling HTML5 Validation

0
COM
To change the style of the validation message bubble, four div elements with pseudo-classes are used:


::-webkit-validation-bubble
::-webkit-validation-bubble-arrow-clipper
::-webkit-validation-bubble-arrow
::-webkit-validation-bubble-message


You can clearly see the change in the validation message bubble


Before Styling

After Styling

Let's add some style in the validated input field I've created here:

CSS:


::-webkit-validation-bubble-arrow
{
border:2px solid #F00;
background:#FD8484;
-webkit-box-shadow:none;
}
::-webkit-validation-bubble-message
{
position: relative;
color:#F00;
background:#FD8484;
border:2px solid #F00;
-webkit-box-shadow: 2px 2px 3px rgba(0,0,0,0.333);
}

This is what it will give:

After Styling

You can learn more about this styling at WebKit wiki.
Credit goes to  WebKit wiki 

HTML5 Form Validation

0
COM
To validate a form in HTML5, you don't need to write tons of code, it is as easy as copy and paste in HTML5. All you have to do is this:


The 'required' attribute : 
To make the field required for the user, just add a 'required' attribute in any input field:


Your Name: <input type="text" name="name" required>


which gives you


The 'required' attribute
Other input types :
There are many other input types in HTML5 which gives you full control to validate you forms, some of the commonly used are given below:


1. Email : 
The input field with email attribute accepts only email addresses:


Your Email: <input type="email" name="email">
<input type="submit" name="submit" value="Submit">




Email Validation


2. Number :
The number attribute gives the user numbers to select, for example Age.


Enter Age: <input type="number" name="age">


You can define the 'min' and 'max' attributes to constrain the field:


Enter Age: <input type="number" name="age" min="18" max="50">


Number Attribute

3. Url :
The url attribute let you to take urls from user:

Enter URL: <input type="url" name="website">

URL Attribute

Similarly, there are other attributes by which you can validate your form:

  • search
  • date
  • month
  • week
  • tel
  • time
  • color
Now the question is can we style the validation bubble? And surely the answer is yes. The next tutorial shows you how to give style to the validation bubble.

How to give shadow in css

0
COM
To give shadow, box-shadow property is used.
Here is the general syntax to use this property:


box-shadow:h-value v-value blur spread color inset;


Let's make a rectangle with some shadow effect:
CSS:

.shadow
{
width:250px;
height:250px;
background-color:#666;
box-shadow:10px 10px 10px 5px #333;
-webkit-box-radius:10px 10px 10px 5px #333;
-moz-box-shadow:10px 10px 10px 5px #333;
}

HTML



   <div class="shadow"></div>



Here is what we create:




How to select the largest value in MySQL?

0
COM
To return the largest value from a column, MAX() function is used.
Here is the syntax:


SELECT MAX(column_name) FROM table_name



Example:
Look at the following "Orders" table. Now we want to find the largest value of the "OrderPrice" column.


OrderIdOrderDateOrderPrice
12010/11/121000
22010/10/231600
32010/09/02700
42010/09/03300
52010/08/302000
62010/10/04100


This can be done by using this statement:

SELECT MAX(OrderPrice) FROM Orders

Result:
2000