Sunday, April 24, 2016

Delete Data in SQL Database using PHP

In my last three posts i covers the topics that how to create connection insert data and then if we want to update that data so then how to update data in in sql database table using php.

For step by step learning see my privies posts on database and php.









Today in this post we delete a record from login table we take a form inputs from user where he gave us the name and password of the user which he want to delete.


<?php
include "conn.php";

$user = $_POST['user'];
$pass = $_POST['password'];


$sql = "DELETE from login 
        where user='".$user."' and PASSWORD='".$pass."' ";

if ($conn->query($sql) === TRUE) {
    echo "Record Deleted successfully";

} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>




Wednesday, April 13, 2016

Create Connection with SQL Database in PHP

How to create connection with mysql database using PHP ?

So for this first create a database in myPhpAdmin and then use that name in mysqli default constructor by default the password was null and user name is root. If you are using XAMP then the servername is localhost.


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

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} else{
echo "Connection Sucssful";
}

?>


copy paste above code save in conn.php file and run on localhost like localhost/conn.php

Saturday, April 9, 2016

View Details On Mouse Click Using Java-Script and HTML

If You Click on the element then it will show its description.




This is First Option
here
is some 
description
This is Second Option
here
is some 
description
This is Third Option
here
is some
 description
This is Fourth Option
here
is some
 description
This is Fifth Option
here
is some
 description


Download Complete Code From Here



HTML Code:
<body>
<div class="main">
<p class="option" onclick="foo(this)" id="1">This is First Option<img src="http://www.clipartbest.com/cliparts/dT6/xXE/dT6xXEpT9.png"></p>
<div class="dec" id="a1"><pre>here
is some 
description</pre></div>
</div>

<div class="main">
<p class="option" onclick="foo(this)" id="2">This is Second Option<img src="http://www.clipartbest.com/cliparts/dT6/xXE/dT6xXEpT9.png"></p>
<div class="dec" id="a2"><pre>here
is some 
description</pre></div>
</div>

<div class="main">
<p class="option" onclick="foo(this)" id="3">This is Third Option<img src="http://www.clipartbest.com/cliparts/dT6/xXE/dT6xXEpT9.png"></p>
<div class="dec" id="a3"><pre>here
is some
 description</pre></div>
</div>

<div class="main">
<p class="option" onclick="foo(this)" id="4">This is Fourth Option<img src="http://www.clipartbest.com/cliparts/dT6/xXE/dT6xXEpT9.png"></p>
<div class="dec" id="a4"><pre>here
is some
 description</pre></div>
</div>

<div class="main">
<p class="option" onclick="foo(this)" id="5">This is Fifth Option<img src="http://www.clipartbest.com/cliparts/dT6/xXE/dT6xXEpT9.png"></p>
<div class="dec" id="a5"><pre>here
is some
 description</pre></div>
</div>
<h1 style="text-align:center;text-shadow:10px 10px 10px red;">""Click on Option to View its Discription""<br><span style="color:blue">Develper:Usman Siddique</span></h1>
</body>


Java-Script Code:

<script>
function foo(getid){
var x = document.getElementById('a'+(getid.id));
if(x.style.display=="block")
{
x.style.display="none";}
else{x.style.display="block";}
}
</script>


CSS Code:
<style>
.main p img{height: 3%;float: left;width: 10%;}
body{background-color:wheat;}
.main{border: 2px solid;width: 20%;margin: auto;background-color:skyblue;box-shadow: 2px 2px 50px hotpink;padding: 10px;}
.option{border: 2px solid wheat;padding:5px;text-align:center;margin: 0px;cursor:pointer}
.dec{background-color: whitesmoke;padding: 5px;display: none; }
</style>

Show Details On Mouse Hover Using CSS HTML


This will show details of an option when the mouse pointer is on that specific option.



Display Discription
This is First Option
here
is some 
description
This is Second Option
here
is some 
description
This is Third Option
here
is some
 description
This is Fourth Option
here
is some
 description
This is Fifth Option
here
is some
 description


Download The Complete Code From here


The HTML Code is:
<body>
<div class="main">
<p class="option" onclick="foo()">This is First Option</p>
<div class="dec"><pre>here
is some
description</pre></div>
</div>

<div class="main">
<p class="option" onclick="foo()">This is Second Option</p>
<div class="dec"><pre>here
is some
description</pre></div>
</div>

<div class="main">
<p class="option" onclick="foo()">This is Third Option</p>
<div class="dec"><pre>here
is some
 description</pre></div>
</div>

<div class="main">
<p class="option" onclick="foo()">This is Fourth Option</p>
<div class="dec"><pre>here
is some
 description</pre></div>
</div>

<div class="main">
<p class="option" onclick="foo()">This is Fifth Option</p>
<div class="dec"><pre>here
is some
 description</pre></div>
</div>
<h1 style="text-align:center;text-shadow:10px 10px 10px red;">""Take Pointer on Option to View its Discription""<br><span style="color:blue">Develper:Usman Siddique</span></h1>


</body>


CSS Code:
<style>
body{background-color:wheat;}
.main{border: 2px solid;width: 20%;margin: auto;background-color:skyblue;box-shadow: 2px 2px 50px hotpink;padding: 10px;}
.option{border: 2px solid wheat;padding:5px;text-align:center;margin: 0px;cursor:pointer}
.dec{background-color: whitesmoke;padding: 5px;display: none; }
.option:hover + .dec{display: block;}
.dec:hover{display: block;}
</style>


Friday, April 8, 2016

Type Casting in Java: Type Conversion in Java


Convert Sting to Int:

String str = "1234";
int foo = Integer.praseInt(str);

Convert Char to Int:

char a = '3';
int foo = (int) a-48;

String to Char Array:

String str = "1234";
char [] charary = str.toCharArray();

Covert Int to String:

int w=1234;
String se=Integer.toString(w);

Convert Double to int:

double x=22.4;
int a= (int)x;

Convert long to int:

long a =10;
int  s = (int) a;

Convert String to BigInteger:


String b="1234422";

BigInteger a=new BigInteger(b); 

Thursday, April 7, 2016

File Handling in Java::Reading and Writing

Reading and writing files in Java using Formatter, Scanner and bufferedreader:


Simple Open a File in Java:

package myfirstproject;
import java.io.*;
public class MyFirstProject {  
    public static void main(String args[]) throws IOException
   {
      File name=new File("C:\\usman\\input.txt");
      if(name.exists()){
          System.out.println(name.getName()+"File is exists");
      }
      else{
          System.out.println("File does not exists");
      }
}
}


Craete New File in Java:

package myfirstproject;
import java.io.*;
import java.util.*;

public class MyFirstProject {  
    public static void main(String args[]) throws IOException
   {
       /*final Formatter x;
       x =new  Formatter("C:\\usman\\fatima.txt");
     
     
*/      File name=new File("C:\\usman\\input1.txt");
        name.createNewFile();
      if(name.exists()){
          System.out.println(name.getName()+"File is exists");
      }
      else{
          System.out.println("File does not exists");
      }
}


}Write in File Using Formatter in Java:
package myfirstproject;
import java.io.*;
import java.util.*;
import java.lang.*;

public class MyFirstProject {  
    public static void main(String args[]) throws IOException
   {
       final Formatter x;
       x = new Formatter("C:\\usman\\usman.txt");
       x.format("%s%s%s%d", "usman " ,"Siddique ", "fatima " ,3);
     
       File name=new File("C:\\usman\\usman.txt");
       if(name.exists()){
           System.out.println("true");
      }
     
       x.close();
}

}



Reading File Using Scanner in Java:
package myfirstproject;
import java.io.*;
import java.util.*;
import java.lang.*;

public class MyFirstProject {  
    private Scanner a;
    public static void main(String args[]) throws IOException
   {
       final Formatter x;
       x = new Formatter("C:\\usman\\input.txt");
     
        MyFirstProject obj=new MyFirstProject();
        obj.a=new Scanner(new File("C:\\usman\\usman.txt"));
        while(obj.a.hasNext()){
            String value=obj.a.next();
       x.format("\n%s\t%d", value  ,3);
        }
       File name=new File("C:\\usman\\usman.txt");
       if(name.exists()){
           System.out.println("true");
      }
     
       x.close();
}

}

Saturday, March 26, 2016

Thursday, February 25, 2016

Simple CV Using HTML and CSS .... About Me Example

HTML:-


<div class="bod">
          <div class="pro">
                 <img src="a.jpg" class="img1">
          </div>
<div class="intro">
   <p class="p1">Hafiz Muhammad Usman Siddique</p>
    <p class="p2">"I am usman.A little boy with big attributes.An empty pocketed with big                ideas in mind.A courage to do big thing but did'nt do any thing yet .lol"</p>

</div>
<div class="second">

<table class="he"  align="center" cellspacing="31px">
<tr><th colspan="3">Skills<hr></th></tr>
<tr>
<td>CSS</td>
<td>HTML</td>
<td>PHP</td></tr>
</table>

<table border="1" align="center" >
<tr><th colspan="2">EDUCATION</th><th colspan="2">INTERNSHIP</th><th colspan="2">PROJECTS</th><th colspan="2">CONTACT</th></tr>
<tr><th rowspan="2">School:</th><td>F G Public School</td>
<th rowspan="2">Ptcl:</th><td>F G Public School</td>
<th rowspan="2">Web:</th><td>F G Public School</td>
<th rowspan="2">Email:</th><td>m7u786@gmail.com</td></tr>
<tr><td>2001-2010</td><td>2001-2010</td></tr>
<tr><th rowspan="2">Collage:</th><td>HITEC Collage For Boys</td>
<th rowspan="2">Lrims:</th><td>F G Public School</td>
<th rowspan="2">Android:</th><td>F G Public School</td>
<th rowspan="2">Mob No:</th><td>03075230948</td></tr>
<tr><td>2011-2012</td></tr>
<tr><th rowspan="2">University:</th><td>Comsats Wah Campus</td>
<th rowspan="2">Codingboths:</th><td>F G Public School</td>
<th rowspan="2">Desktop:</th><td>F G Public School</td>
<th rowspan="2">Address:</th><td>HIT Taxila Cantt,Rawalpindi</td></tr>
<tr><td>2013-2017</td></tr>
<tr><th colspan="2"></th><th colspan="2">Description</th><th colspan="2">Description</th><th colspan="2">Description</th></tr>
<tr><th colspan="2"><pre>i
e-resizee
e</pre></th><th colspan="2"></th><th colspan="2"></th><th colspan="2">.</th></tr>

</div>
</div>



CSS:-


<style>
.he td{border-radius:100px;width:100px;height:100px;text-align:center;border:1px solid ;}
.he {padding:15px;}
.p1{font-weight:bold;font-size:20px;text-align:center;}
.pro{padding-left:43%;padding-top:5%;background-color: #aff;}
.intro{background-color:#eee;}
.second{background-color:#ee9;}
.img1{width: 200px;border-radius: 100px;height: 200px; }
.p2{text-align:center;}body{background-color:whitesmoke;}
.bod{background-color:#eee}
</style>




Tuesday, February 9, 2016

XML - Display XML in browser in Graphical Form Using CSS

XML stands for EXtensible Markup Language.
XML was designed to store and transport data.
XML was designed to be both human- and machine-readable.








XML Document:-


<?xml-stylesheet type="text/css" href="xmlstyle.css"?>
<personal_info>
Thats My Personal Information:- 
<self_intro>
It Show Only Self introduction:-
<name>Name: Hafiz Muhammad Usman Siddique</name>
<mob_no>Mob No: 03075230948</mob_no>
</self_intro>
<education>
It show some Educational introduction:-
<reg_no>Reg No: FA13-BSE-080</reg_no>
<university>University : Comsats Wah Campus</university>
</education>

</personal_info>

CSS File:-


personal_info{color:red;font-weight: bold;border: 1px solid black;width: 24%;padding: 20px;margin: 20px;text-decoration: underline;
}
self_intro{color:green;display: block;padding: 10px;text-decoration: none;
}
name{color:blue;display: block;padding-left: 20px;
}
mob_no{color:orange;display: block;padding-left: 20px;
}
education{color:brown;display: block;padding: 10px;
}
reg_no{color:pink;display: block;padding-left: 20px;
}
university{color:black;padding-left: 20px;
}

Friday, December 11, 2015

HTML form validation using Java-Script














<html>
<head>
<title>Form Validation using JavaScript</title>
</head>
<body>

<form name="form1" action="formvalidation.html" onsubmit="return validate()" method="post">
<input type="text" name="username">
<input type="submit" value="Submit">
</form>
<script type="text/javascript">
function validate() {
    var x = document.forms["form1"]["username"].value;
    if (x == null || x == "") {
        alert("Name must be filled out");
        return false;
}
}
</script>
</body>
</html>

Friday, November 27, 2015

Up-Date record in SQL Database using C#.net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Data;
using System.Data.SqlClient;

namespace WebApplication1
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            SqlConnection cnn = new SqlConnection(@"Data Source=localhost\SQLExpress;Initial Catalog=awais;Integrated Security=True;Integrated Security=True ");
            cnn.Open();
string query = "update logout set name ='"+TextBox3.Text+"' where name = '" + TextBox2.Text + "';";
            SqlCommand cmd = new SqlCommand(query, cnn);
            cmd.ExecuteNonQuery();

            Response.Write("update  is done!");

        }

   
    }
}


Friday, November 20, 2015

Retrieve / Collect data from SQL database using c#.Net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

 
        protected void Button2_Click(object sender, EventArgs e)
        {

            try
            {
                SqlConnection cnn = new SqlConnection(@"Data Source=localhost\SQLExpress;Initial Catalog=awais;Integrated Security=True;Integrated Security=True ");
                cnn.Open();
                SqlCommand command = new SqlCommand("SELECT name,password from logout;", cnn);


                SqlDataReader reader = command.ExecuteReader();

                if (reader.HasRows)
                {
                    Response.Write("<table border=\"3\">");
                    while (reader.Read())
                    {
                        Response.Write("<tr><th width=\"40\">"+ reader.GetString(0) +"</th><th>"+ reader.GetString(1)+"</th></tr>");
                    } Response.Write("</table>");
                }
                else
                {
                    Response.Write("No rows found.");
                }
                reader.Close();
            }
            catch (SystemException ex) { Response.Write(ex); }
           
        }
    }
}


Saturday, October 24, 2015

Measurement Scales Converter in vb.net


Vb.net Code:-

Public Class WebForm1
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim a As Single
        Dim b As Single

        Dim c As Single
        Dim inch As Single
        Dim yard As Single
        Dim meter As Single
        Dim fathom As Single
        Dim rod As Single
        Dim furlong As Single
        Dim kilometer As Single
        Dim mile As Single
        Dim foot As Single
        yard = 3
        meter = 3.28155
        fathom = 6
        rod = 16.5
        furlong = 660
        kilometer = 32815
        mile = 5280
        If Val(TextBox1.Text) = 1 Then
            a = inch
        End If
        If TextBox1.Text = 2 Then
            a = yard
        End If
        If TextBox1.Text = 3 Then
            a = meter
        End If
        If TextBox1.Text = 4 Then
            a = fathom
        End If
        If TextBox1.Text = 5 Then
            a = rod
        End If
        If TextBox1.Text = 6 Then
            a = furlong
        End If
        If TextBox1.Text = 7 Then
            a = kilometer
        End If
        If TextBox1.Text = 8 Then
            a = mile
        End If
        If Val(TextBox2.Text) = 1 Then
            b = inch
        End If
        If TextBox2.Text = 2 Then
            b = yard
        End If
        If TextBox2.Text = 3 Then
            b = meter
        End If
        If TextBox2.Text = 4 Then
            b = fathom
        End If
        If TextBox2.Text = 5 Then
            b = rod
        End If
        If TextBox2.Text = 6 Then
            b = furlong
        End If
        If TextBox2.Text = 7 Then
            b = kilometer
        End If
        If TextBox2.Text = 8 Then
            b = mile
        End If
        c = Val(TextBox3.Text) * a

        Dim ans As Integer

        ans = c / b
        TextBox4.Text = ans




    End Sub
End Class




Form:-



HTML CODE:-

Monday, October 5, 2015

Polymorphism in C# : Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication5
{
    class Shape
    {
        protected int width, height;
        public Shape()
        {
        }
        public virtual void area(int width, int height)
        {
            Console.WriteLine("Parent class area :");
            Console.WriteLine("Shape has no spasific area ");
        }
    }

    class Rectangle : Shape
    {
        public Rectangle() : base()
        {

        }
        public override void area(int width, int height)
        {
            Console.WriteLine("Rectangle class area :");
            Console.WriteLine(width * height);
        }
    }
   
    class Triangle : Shape
    {
        public Triangle() : base()
        {

        }
        public new void area(int width,int height)
        {
            Console.WriteLine("Triangle class area :");
            Console.WriteLine(width * height / 2);
        }
    }
   
    class Tester
    {

        static void Main(string[] args)
        {
            Shape s = new Shape();
            Rectangle r = new Rectangle();
            Triangle t = new Triangle();
            s.area(0,0);
            r.area(10,7);
            t.area(10,5);

            Shape s1 = new Rectangle();
            s1.area(10, 15);

            Shape s2 = new Triangle();
            s2.area(22, 76);

            Console.ReadKey();
        }
    }
}