Thursday, 22 March 2012

What is difference between inner join, left join and right join in SQL? 



Problem: How to insert integer and string in SQL Query using PHP?
Impact: You can’t insert in DB if Data type aren’t match!
Solution: in Query syntax for integer data type use “ ” and for string data type use ‘ “ “ ‘.
Like:  
<?php
      if(isset($_POST['Insert']))
      {
            $id_sidebar = $_POST['id'];
            $title_sidebar = $_POST['title'];
            $body_sidebar = $_POST['body'];
            $url_sidebar = $_POST['url'];
            $insert = "INSERT INTO Sidebar(id_sidebar, title_sidebar, body_sidebar, url_link) VALUES (".$id_sidebar.",'".$title_sidebar."','".$body_sidebar."','".$url_sidebar."')";
      }
?>
<form name="myform"  method="post" action="newfile.php">
    ID:<input name="id" type="text" value="<?php echo $id_sidebar;?>"/><br /><br/>
      Title:<input name="title" type="text" value="<?php echo $title_sidebar;?>"/><br /><br/>
      Body:<input name="body" type="text" value="<?php echo $body_sidebar;?>"/><br /><br/>
      Url:<input name="url" type="text" value="<?php echo $url_sidebar;?>"/><br /><br/>
      <input type="submit" value="Insert" name="Insert"/>
</form>

In this sample data type for ‘id_sidebar’is integer and data type for ‘title_sidebar’ is string.

Thursday, 15 March 2012

What is different between HTML5 and HTML4?

HTML5 syntax is almost exactly like HTML4, they are compatible together and all current browsers support HTML5. In below are some of different between HTML5 & HTML4
  • DOCTYPE isn’t required
  • <audio><video> tages
  • graphic include
  • storage location on client side (in HTML4 browser cache used as temporary storage)
  • only modern browser support
  • Not needed in HTML5: type="text/css" ,  type="text/javascript",  <link rel="stylesheet" … />
  • Self-closing tag can now end with just the >,  <br /> can now be <br> again
Instead of div tag you can use different tags like:

<header>, <nav>, <section>, <article>, <aside>, <figure>, <hgroup> and <footer>

<header>: replace div id="header"
<hgroup> : for grouping a series of <h#> tags
<nav> :  links to other pages or parts within the page
<section> : a grouping of content elements inside, section element by itself with more sections within and replace div id="content"
<article>: Standalone content that can be republished, nesting article elements. Example: user comments on a blog entry. Do not over use, it's not a replacement for the div tag
<aside> : for separate from the main content of the page and could be nested inside other article or section elements. Use for quotes, blog , advertising, groups of content.
<figure> : for separate image and image’s content
<footer>: contains info section such as who wrote it, links to related documents, copyright data, etc. Cannot put a header or article tag and replace of <div id="footer">

When to use div? For content being grouped simply for stylistic reasons. We use div, when no other element is suitable.
Use <b> or <i> to bold and italicize content for stylistic reasons. Use <strong> or <em> to stress the meaning of the content.

CSS Reset file? Removes browser inconsistent default styling of HTML elements. Such as height, font sizes, margins, headings, etc. We have to add ‘@import url("reset.css");’ in JavaScript file.

CSS concept...
Different between id and class:
      Ids are to be used only once in your HTML layout.
    Classes can be used multiple times. Ids have priority over classes. So, if an element has a both id and class, the id will take over.
     Sample: Id: #id_name {}     class: .id_name{}

·  Different between padding and margin: 
     Padding is the space inside the border between the border and the actual image or contents.
     Margins are the spaces outside the border, between the border and the other elements.

 



  When you have interview, it is very Common question that you have to know about Object Oriented Programming (OOP) is...

     Three main concepts?
Inheritance:  Child: parent
Class can associate with each other a ‘child and parent’ relationship. They are share similar properties and method (4 wheels and doors). ‘Car is parent class and SUV and Sport have child class.
Encapsulation:  Like  private, protected and public class in ASP.NET
A class having an interface and this class is available to use. (Break or gas class for vehicle). The data for the object are hidden behind its interface. Purpose is keeping the class logic 'unchangeable'.
Polymorphism: Like Virtual class in ASP.NET
It is possible to call the method without worrying about its internal type; this allows ignoring the details of special classes.
Difference between <input type='button' /> and <input type='submit' /> in HTML
  • Button: button will not submit a form - they don't do anything by default. They're generally used in conjunction with JavaScript as part of an AJAX application.
  • Submit: buttons will submit the form they are in when the user clicks on it.