Fundamentals
Introduction
1st Android Application

OOPS Concepts
Class
Object
Abstraction
Encapsulation

Polymorphism
Inheritance
Message Passing
Dynamic Binding

UI Controls
TextView
Button
Toggle Button
CheckBox
Radio Button
Spinner
ProgressBar
SeekBar
RadioGroup
RatingBar
Switch
EditText
AutoComplete
TextView

MultiAutoComplete
TextView

ImageView
ImageButton
Gallery
MediaPlayer
VideoView
MediaController

TimePicker
DatePicker
CalendarView
Chronometer
Analog Clock
Digital Clock

Layouts
LinearLayout
RelativeLayout
GridLayout
TableLayout
FrameLayout
Fragment

Composite
ListView
ExpandableListView
GridView
ScrollView
SearchView
Sliding Drawer
Tab Widget
WebView

Transitions
Image Switcher
StackView
TextSwitcher
ViewAnimator
View Flipper
View Switcher

Advanced
Request Focus
View
View Stub
TextureView
Gesture Overlay View

SurfaceView
NumberPicker
Zoom Button
Zoom Controls
AbsoluteLayout

Database
SharedPreference
SQLite DB
MySQL DB

Webservices
Check HttpURLConnection
Single Webservice Call
Multi Webservice Call
ListView from Webservice
SQLite from Webservice
Data from Database

Telephone Manager
IMEI
IMSI
Phone Type
Sim Type
Network Type

Content Providers
Contact Provider
BookMark Provider
Own Provider


Message & Networking
Send SMS
SMS with Reports
Group SMS

Send E-Mail
Download Binary Data


Location Based Service
Display Google Map
Events with Google Map

Android Services
Create Service
Create Longtime Service

Asynchronous Task
Repeating Services
IntentService

Activity from a Service
Bind Activity to Service


Sample Projects
HMS
CNB
Login Screen
Camera Event
Browse Option
QR Code Events
Accelerometer Sensor
EditText from Spinner

Android Sample Projects - College Notice Board


Note                     Download ADT Plugin Here.
Here I am using,
OS : Linux (Ubuntu 12.04)
Eclipse : Juno (Version 4.2.0)
Android API Level : 3 to 'n' as per need
Emulator API Level : It will be displayed in output image


At finally i have created one Android Application for Notice Board (College Notice Board). In that, i declared four groups (Admin, HOD, Staff, Student) and its individual ((Admin-> Chairman, Director, CEO, Principal), (HOD-> HOD1, HOD2, HOD3, HOD4), (Staff-> Staff1, Staff2, Staff3, Staff4), (Student-> Boy1, Boy2, Girl1, Girl2)). Here anyone can post their new Message in CNB and also Tag it to given Groups. Sender only can update their Previous Message and taged groups only can see that messages..

Use Case Diagram for CNB
Output


Step 1 : Create a database named as cnb and import the below code

-- phpMyAdmin SQL Dump
-- version 3.4.10.1deb1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Dec 11, 2012 at 03:38 PM
-- Server version: 5.5.24
-- PHP Version: 5.3.10-1ubuntu3.2

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
 

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
 
--
-- Database: `cnb`
--

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

--
-- Table structure for table `admin`
--

CREATE TABLE IF NOT EXISTS `admin` (
  `ad_id` varchar(25) NOT NULL,
  `ad_name` varchar(50) NOT NULL,
  `ad_pwd` varchar(50) NOT NULL,
  `ad_cnbid` int(11) NOT NULL DEFAULT '1',
  PRIMARY KEY (`ad_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
--
-- Dumping data for table `admin`
--

INSERT INTO `admin` (`ad_id`, `ad_name`, `ad_pwd`, `ad_cnbid`) VALUES
('1', 'Chairman', 'chairman', 1),
('2', 'Director', 'director', 1),
('3', 'CEO', 'ceo', 1),
('4', 'Principal', 'principal', 1);
 
-- --------------------------------------------------------

--
-- Table structure for table `cnb`
--

CREATE TABLE IF NOT EXISTS `cnb` (
  `cnb_id` int(11) NOT NULL,
  `cnb_name` varchar(50) NOT NULL,
  `cnb_pwd` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`cnb_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
--
-- Dumping data for table `cnb`
--

INSERT INTO `cnb` (`cnb_id`, `cnb_name`, `cnb_pwd`) VALUES
(1, 'Admin', 'admin'),
(2, 'Hod', 'hod'),
(3, 'Staff', 'staff'),
(4, 'Student', 'student');
 
-- --------------------------------------------------------

--
-- Table structure for table `header`
--

CREATE TABLE IF NOT EXISTS `header` (
  `se_cnbid` int(11) NOT NULL,
  `se_uid` varchar(50) NOT NULL,
  `msg_id` int(11) NOT NULL,
  `msg` varchar(500) NOT NULL,
  `re_cndid` int(11) NOT NULL,
  `dt` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
--
-- Dumping data for table `header`
--

INSERT INTO `header` (`se_cnbid`, `se_uid`, `msg_id`, `msg`, `re_cndid`, `dt`) VALUES
(1, '3', 1, 'All Student must assemble in Auditorium at 10 am', 4, '2012-12-03 10:31:14'),
(1, '3', 2, 'Hello', 4, '2012-12-08 10:37:58'),
(1, '3', 2, 'Hello', 2, '2012-12-08 10:37:58'),
(1, '3', 6, 'development cell', 1, '2012-12-08 10:42:17'),
(1, '3', 6, 'development cell', 2, '2012-12-08 10:42:17'),
(1, '3', 6, 'development cell', 3, '2012-12-08 10:42:17'),
(1, '3', 6, 'development cell', 4, '2012-12-08 10:42:17'),
(4, '1', 7, 'Testing success', 2, '2012-12-11 15:19:52'),
(4, '1', 7, 'Testing success', 4, '2012-12-11 15:19:52'),
(4, '2', 5, 'Good Day', 4, '2012-12-07 16:51:27'),
(4, '2', 5, 'Good Day', 3, '2012-12-07 16:51:27'),
(4, '2', 5, 'Good Day', 2, '2012-12-07 16:51:27'),
(1, '4', 4, 'college', 4, '2012-12-07 16:48:49'),
(4, '2', 5, 'Good Day', 1, '2012-12-07 16:51:27'),
(1, '4', 4, 'college', 3, '2012-12-07 16:48:49'),
(1, '4', 4, 'college', 2, '2012-12-07 16:48:49'),
(1, '4', 4, 'college', 1, '2012-12-07 16:48:49');
 
-- --------------------------------------------------------

--
-- Table structure for table `hod`
--

CREATE TABLE IF NOT EXISTS `hod` (
  `ho_id` int(11) NOT NULL,
  `ho_name` varchar(50) NOT NULL,
  `ho_pwd` varchar(50) NOT NULL,
  `ho_cndid` int(11) NOT NULL DEFAULT '2',
  PRIMARY KEY (`ho_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
--
-- Dumping data for table `hod`
--

INSERT INTO `hod` (`ho_id`, `ho_name`, `ho_pwd`, `ho_cndid`) VALUES
(1, 'HOD1', 'hod1', 2),
(2, 'HOD2', 'hod2', 2),
(3, 'HOD3', 'hod3', 2),
(4, 'HOD4', 'hod4', 2);
 
-- --------------------------------------------------------

--
-- Table structure for table `staff`
--

CREATE TABLE IF NOT EXISTS `staff` (
  `stf_id` int(11) NOT NULL,
  `stf_name` varchar(50) NOT NULL,
  `stf_pwd` varchar(50) NOT NULL,
  `stf_cndid` int(11) NOT NULL DEFAULT '3',
  PRIMARY KEY (`stf_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
--
-- Dumping data for table `staff`
--

INSERT INTO `staff` (`stf_id`, `stf_name`, `stf_pwd`, `stf_cndid`) VALUES
(1, 'Staff1', 'staff1', 3),
(2, 'Staff2', 'staff2', 3),
(3, 'Staff3', 'staff3', 3),
(4, 'Staff4', 'staff4', 3);
 
-- --------------------------------------------------------

--
-- Table structure for table `student`
--

CREATE TABLE IF NOT EXISTS `student` (
  `std_id` int(11) NOT NULL,
  `std_name` varchar(50) NOT NULL,
  `std_pwd` varchar(50) NOT NULL,
  `std_cndid` int(11) NOT NULL DEFAULT '4',
  PRIMARY KEY (`std_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
--
-- Dumping data for table `student`
--

INSERT INTO `student` (`std_id`, `std_name`, `std_pwd`, `std_cndid`) VALUES
(1, 'Boy1', 'boy1', 4),
(2, 'Boy2', 'boy2', 4),
(3, 'Girl1', 'girl1', 4),
(4, 'Girl2', 'girl2', 4);
 
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
 

Step 2 : Select File -> New -> Project -> Android Application Project (or) Android Project. Fill the forms and click "Finish" button. If you have any doubt regarding create a new project Click Here.

Step 3 : Open res -> layout -> samplecodez.xml and add following code :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
 
    <TextView
        android:id="@+id/textView1"
        android:textSize="40dp"
        android:textStyle="bold"
        android:textColor="#4169E1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="SampleCodez" />
 
</RelativeLayout>

Step 4 : Open res -> layout -> cnb_login.xml and add following code :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
 
    <TextView
        android:id="@+id/textView1"
        android:textSize="23dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="50dp"
        android:text="College Notice Board" />
 
    <Spinner
        android:id="@+id/spinner1"
        android:layout_width="wrap_content"
        android:layout_height="60dp"
        android:layout_below="@+id/textView1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="40dp" />
 
    <EditText
        android:id="@+id/editText1"
        android:hint="Password"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/spinner1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="20dp"
        android:inputType="textPassword" />
 
    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/editText1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="28dp"
        android:text="Go" />
 
</RelativeLayout>

Step 5 : Open res -> layout -> user_login.xml and add following code :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/rl"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
 
    <Spinner
        android:id="@+id/spinner1"
        android:layout_width="wrap_content"
        android:layout_height="60dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="80dp" />
 
    <EditText
        android:id="@+id/editText1"
        android:hint="Password"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/spinner1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="30dp"
        android:inputType="textPassword" />
 
    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/editText1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="50dp"
        android:text="Login" />
 
</RelativeLayout>

Step 6 : Open res -> layout -> noticeboard.xml and add following code :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/rl"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
 
    <TextView
        android:id="@+id/textView1"
        android:textSize="25dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="20dp" />
 
    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="30dp" >
 
        <LinearLayout
            android:id="@+id/linear1"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
            
            
        </LinearLayout>
        
    </ScrollView>
 
</RelativeLayout>

Step 7 : Open res -> menu -> noticeboard.xml and add following code :

<menu xmlns:android="http://schemas.android.com/apk/res/android">
            
    <item 
        android:id="@+id/home"
        android:title="Home"
        android:showAsAction="never" />
    
    <item 
        android:id="@+id/logout"
        android:title="Logout"
        android:showAsAction="never" />
        
    <item 
        android:id="@+id/newmsg"
        android:title="Post"
        android:showAsAction="never" />
    
    <item 
        android:id="@+id/update"
        android:title="Update"
        android:showAsAction="never" />
    
    <item 
        android:id="@+id/refresh"
        android:title="Refresh"
        android:showAsAction="never" />
    
</menu>

Step 8 : Open src -> package -> SampleCodez.java and add following code :

package balaji.cnb;
 
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
 
public class SampleCodez extends Activity 
{
	
	protected boolean active = true;
	protected int splashTime = 5000;
	
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.samplecodez);
        
        Thread splashTread = new Thread()
        {
            @Override
            public void run() 
            {
                try 
                {
                    int waited = 0;
                    
		    while(active && (waited < splashTime)) 
                    {
                        sleep(40);
                        if(active)
                        {
                            waited += 100;
                        }
                    }
                } 
                catch(InterruptedException e)
                {
                    // do nothing
                } finally 
                {
                    finish();
                    startActivity(new Intent(SampleCodez.this,NetConnection.class));
                }
            }
        };
        splashTread.start();
    }
}

Step 9 : Open src -> package -> NetConnection.java and add following code :

package balaji.cnb;
 
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
 
public class NetConnection extends Activity {
	

	private SharedPreferences prefs;
	private String prefName = "report";
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        try {
        	prefs = getSharedPreferences(prefName, MODE_PRIVATE);
        	String net_ip=prefs.getString("ip", "http://10.0.2.2/cnb/");
        	
        	URL url = new URL(net_ip);
        	executeReq(url);
        	SharedPreferences.Editor editor = prefs.edit();
        	editor.putInt("connection", 1);
        	editor.commit();
 
        	finish();
        	startActivity(new Intent(NetConnection.this,CNB_Login.class));            
        }
        catch(Exception e)
        {
        	Toast.makeText(getApplicationContext(), "Check Network Connection " +
        			"and IP Address ", Toast.LENGTH_LONG).show();
 
        	SharedPreferences.Editor editor = prefs.edit();
        	editor.putInt("connection", 0);
        	editor.commit();
                
        	finish();
        	startActivity(new Intent(NetConnection.this,CNB_Login.class));
        }
    }
        
    public void executeReq(URL urlObject) throws IOException {
        	
    	HttpURLConnection conn = null;
    	conn = (HttpURLConnection) urlObject.openConnection();
    	conn.setReadTimeout(30000);//milliseconds
    	conn.setConnectTimeout(3500);//milliseconds
    	conn.setRequestMethod("GET");
    	conn.setDoInput(true);
 
    	// Start connect
    	conn.connect();
    	InputStream response =conn.getInputStream();
    	Log.d("Response:", response.toString());
    }
}

Step 10 : Open src -> package -> CNB_Login.java and add following code :

package balaji.cnb;
 
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONObject;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
 
public class CNB_Login extends Activity {
	
	Spinner Spinn_Frame;
	EditText Edit_Frame_Pwd;
	Button But_Go;
	
	List<String> List_Frame, List_Frame_Pwd, List_cnbid;
	
	String Str_Frame_Pwd, Str_Alert_Msg, Str_Alert_Title;
	int Int_Frame_Pos;
	
	InputStream is=null;
	String result=null;
	String line=null;
	
	String IP_Address;
	
	private SharedPreferences prefs;
	private String prefName = "report";
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.cnb_login);
        
        prefs = getSharedPreferences(prefName, MODE_PRIVATE);
        int Conn_Check = prefs.getInt("connection", 100);
        
        if(Conn_Check == 0)
        {
	    AlertDialog.Builder Alert_Conn_Error = new AlertDialog.Builder(CNB_Login.this);
	    Alert_Conn_Error.setMessage("Check your Internet Connection..");
	    Alert_Conn_Error.setTitle("Connection Error");
	    Alert_Conn_Error.setPositiveButton("Ok", new OnClickListener() {
				
	        @Override
	        public void onClick(DialogInterface dialog, int which) {
		    // TODO Auto-generated method stub
					
		    finish();
		}
	    });
        	
	    Alert_Conn_Error.show();
        }
        else {
        
        initialise_variables();
                
        ArrayAdapter<String> adp = new ArrayAdapter<String> 
        (this, android.R.layout.simple_expandable_list_item_1, List_Frame);
        adp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        Spinn_Frame.setAdapter(adp);
        Int_Frame_Pos = 0;
        Spinn_Frame.setSelection(Int_Frame_Pos);
        Str_Frame_Pwd = List_Frame_Pwd.get(Int_Frame_Pos).toString();
        
        Spinn_Frame.setOnItemSelectedListener(new OnItemSelectedListener() {
 
		@Override
		public void onItemSelected(AdapterView<?> arg0, View arg1,
				int arg2, long arg3) {
			// TODO Auto-generated method stub
				
			Int_Frame_Pos = arg2;
			Str_Frame_Pwd = List_Frame_Pwd.get(Int_Frame_Pos).toString();
		}
 
		@Override
		public void onNothingSelected(AdapterView<?> arg0) {
			// TODO Auto-generated method stub
				
		}
	});
        
        But_Go.setOnClickListener(new View.OnClickListener() {
			
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
				
			if(Edit_Frame_Pwd.getText().toString().equalsIgnoreCase("")) {
				
				Str_Alert_Msg = "Enter Password !!!";
				Str_Alert_Title = "Error";
				alert_method();
			}
			else {
				
				if(Edit_Frame_Pwd.getText().toString().equals(Str_Frame_Pwd)) {
					
					if(Int_Frame_Pos == 0) {
						
						save();
					}
					if(Int_Frame_Pos == 1) {
						
						save();
					}
					if(Int_Frame_Pos == 2) {
						
						save();
					}
					if(Int_Frame_Pos == 3) {
						
						save();
					}
				}
				else {
					Str_Alert_Msg = "Wrong Password !!!";
					Str_Alert_Title = "Error";
					alert_method();
				}
			}
		}
 
		private void save() {
			// TODO Auto-generated method stub
				
			prefs = getSharedPreferences(prefName, MODE_PRIVATE);
			SharedPreferences.Editor editor = prefs.edit();
		
			//---save the values in the EditText view to preferences---
			editor.putInt("cnb_id", 
				Integer.parseInt(List_cnbid.get(Int_Frame_Pos).toString()));

			//---saves the values---
			editor.commit();
			
			finish();
			
			Intent i = new Intent(CNB_Login.this, USER_Login.class);
			startActivity(i);
			Edit_Frame_Pwd.setText(null);
		}
	});   
        }
    }
    
    public void initialise_variables() {
    	
    	Spinn_Frame = (Spinner) findViewById(R.id.spinner1);
    	Edit_Frame_Pwd = (EditText) findViewById(R.id.editText1);
    	But_Go = (Button) findViewById(R.id.button1);
    	
    	List_Frame = new ArrayList<String>();    	
    	List_Frame_Pwd = new ArrayList<String>();
    	List_cnbid = new ArrayList<String>();
    	
    	prefs = getSharedPreferences(prefName, MODE_PRIVATE);
    	IP_Address = prefs.getString("ip", "http://10.0.2.2/cnb/");
    	
    	DB_CNB_Frame();
    }

    public void DB_CNB_Frame() {
	// TODO Auto-generated method stub
    	
    	try
    	{
    		HttpClient httpclient = new DefaultHttpClient();
    		HttpPost httppost = new HttpPost(IP_Address + "DB_CNB_Frame.php");
    		HttpResponse response = httpclient.execute(httppost); 
    		HttpEntity entity = response.getEntity();
    		is = entity.getContent();    	      
    	}
    	catch(Exception e)
    	{
    		Log.e("DB_CNB_Frame", e.toString());
    	}     
            
    	try
    	{
    		BufferedReader reader = new BufferedReader
    				(new InputStreamReader(is,"iso-8859-1"),8);
    		StringBuilder sb = new StringBuilder();
    		while ((line = reader.readLine()) != null)
    		{
    			sb.append(line + "\n");
    		}
    		is.close();
    		result = sb.toString();    	    
    	}
    	catch(Exception e)
    	{
    		Log.e("DB_CNB_Frame", e.toString());
    	}     
           
    	try
    	{
    		JSONArray jarray = new JSONArray(result);
    		JSONObject jobj = null;
    		
    		for(int i=0; i<jarray.length(); i++) {
    			
    			jobj = jarray.getJSONObject(i);
    			
    			List_Frame.add(jobj.getString("cnb_name"));
    			List_Frame_Pwd.add(jobj.getString("cnb_pwd"));
    			List_cnbid.add(String.valueOf(jobj.getInt("cnb_id")));
    		}
    		
    		prefs = getSharedPreferences(prefName, MODE_PRIVATE);
    		SharedPreferences.Editor editor = prefs.edit();
    		
    		editor.putString("ip", IP_Address);
    		
    		editor.commit();
    	}
    	catch(Exception e)
    	{
    		Log.e("DB_CNB_Frame", e.toString());
    	}
    }
    
    public void alert_method() {
    	
    	AlertDialog.Builder alert = new AlertDialog.Builder(CNB_Login.this);
    	alert.setMessage(Str_Alert_Msg);
    	alert.setTitle(Str_Alert_Title);
    	alert.setPositiveButton("OK", null);
    	alert.show();
    	Edit_Frame_Pwd.setText(null);
    }
    
    @Override
    public void onBackPressed() {
	    // TODO Auto-generated method stub
		
	    finish();		
    }
}

Step 11 : Open src -> package -> User_Login.java and add following code :

package balaji.cnb;
 
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
 
public class USER_Login extends Activity {
	
	private SharedPreferences prefs;
	private String prefName = "report";
	
	Spinner Spinn_Frame;
	EditText Edit_Frame_Pwd;
	Button Butt_Login;
	
	List<String> List_Frame, List_Frame_Pwd, List_uid;
	
	int Int_Frame_Pos, Int_cnbid;
	String Str_Frame_Pwd, Str_Alert_Msg, Str_Alert_Title;
	
	InputStream is=null;
	String result=null;
	String line=null;
	
	String IP_Address;
	
    @Override
    protected void onCreate(Bundle savedInstanceState) {
	    // TODO Auto-generated method stub
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.user_login);

	    initialise_variables();
		
	    Spinn_Frame.setOnItemSelectedListener(new OnItemSelectedListener() {
 
		@Override
		public void onItemSelected(AdapterView<?> arg0, View arg1,
				int arg2, long arg3) {
			// TODO Auto-generated method stub
				
			Int_Frame_Pos = arg2;
			Str_Frame_Pwd = List_Frame_Pwd.get(Int_Frame_Pos).toString();
		}
 
		@Override
		public void onNothingSelected(AdapterView<?> arg0) {
			// TODO Auto-generated method stub
				
		}
	    });
		
	    Butt_Login.setOnClickListener(new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
				
			if(Edit_Frame_Pwd.getText().toString().equalsIgnoreCase("")) {
				
				Str_Alert_Msg = "Enter Password !!!";
				Str_Alert_Title = "Error";
				alert_method();
			}
			else {
				
				if(Edit_Frame_Pwd.getText().toString().equals(Str_Frame_Pwd)) {
					
					if(Int_Frame_Pos == 0) {
						
						save();
					}
					if(Int_Frame_Pos == 1) {
						
						save();
					}
					if(Int_Frame_Pos == 2) {
						
						save();
					}
					if(Int_Frame_Pos == 3) {
						
						save();
					}
				}
				else {
					Str_Alert_Msg = Str_Frame_Pwd;
					Str_Alert_Title = "Error";
					alert_method();
				}
			}
		}
 
		private void save() {
			// TODO Auto-generated method stub
				
			prefs = getSharedPreferences(prefName, MODE_PRIVATE);
			SharedPreferences.Editor editor = prefs.edit();
		        
			//---save the values in the EditText view to preferences---
        		editor.putString("uid", List_uid.get(Int_Frame_Pos).toString());
			editor.putString("uname", List_Frame.get(Int_Frame_Pos).toString());

			//---saves the values---
        		editor.commit();
		
			finish();
		
			Intent i = new Intent(USER_Login.this, NoticeBoard.class);
			startActivity(i);
			
			Edit_Frame_Pwd.setText(null);
		}
	    });
	}
	
	public void initialise_variables() {
		// TODO Auto-generated method stub
		
		Spinn_Frame = (Spinner) findViewById(R.id.spinner1);
		Edit_Frame_Pwd = (EditText) findViewById(R.id.editText1);
		Butt_Login = (Button) findViewById(R.id.button1);
		
		List_Frame = new ArrayList<String>();
		List_Frame_Pwd = new ArrayList<String>();
		List_uid = new ArrayList<String>();
		
		prefs = getSharedPreferences(prefName, MODE_PRIVATE);
		Int_cnbid = prefs.getInt("cnb_id", 1);
		
		prefs = getSharedPreferences(prefName, MODE_PRIVATE);
    		IP_Address = prefs.getString("ip", "http://10.0.2.2/cnb/");
 
		DB_ListFrame();
		
		Int_Frame_Pos = 0;
		
		ArrayAdapter<String> adp = new ArrayAdapter<String>
		(this, android.R.layout.simple_expandable_list_item_1, List_Frame);
		Spinn_Frame.setAdapter(adp);
		Int_Frame_Pos = 0;
		Spinn_Frame.setSelection(Int_Frame_Pos);
        	Str_Frame_Pwd = List_Frame_Pwd.get(Int_Frame_Pos).toString();
	}
	
    	public void DB_ListFrame() {
		// TODO Auto-generated method stub
    	
	    	ArrayList<NameValuePair> name = new ArrayList<NameValuePair>();
	    	
	    	name.add(new BasicNameValuePair("cnbid", String.valueOf(Int_cnbid)));
	    	
	    	try
	    	{
	    		HttpClient httpclient = new DefaultHttpClient();
	    		HttpPost httppost = new HttpPost(IP_Address + "DB_ListFrame.php");
	    		httppost.setEntity(new UrlEncodedFormEntity(name));
	    		HttpResponse response = httpclient.execute(httppost); 
	    		HttpEntity entity = response.getEntity();
	    		is = entity.getContent();    	      
	    	}
	    	catch(Exception e)
	    	{
	    		Log.e("DB_ListFrame", e.toString());
	    	}     
            
	    	try
	    	{
	    		BufferedReader reader = new BufferedReader
	    				(new InputStreamReader(is,"iso-8859-1"),8);
	    		StringBuilder sb = new StringBuilder();
	    		while ((line = reader.readLine()) != null)
	    		{
	    			sb.append(line + "\n");
	    		}
	    		is.close();
	    		result = sb.toString();    	    
	    	}
	    	catch(Exception e)
	    	{
	    		Log.e("DB_ListFrame", e.toString());
	    	}     
		   
	    	try
	    	{
	    		JSONArray jarray = new JSONArray(result);
	    		JSONObject jobj = null;
	    		
	    		for(int i=0; i<jarray.length(); i++) {
	    			
	    			jobj = jarray.getJSONObject(i);
	    			
	    			List_Frame.add(jobj.getString("1"));
	    			List_Frame_Pwd.add(jobj.getString("2"));
	    			List_uid.add(jobj.getString("0"));
	    		}
	    	}
	    	catch(Exception e)
	    	{
	    		Log.e("DB_ListFrame", e.toString());
	    	}
    	}

    	public void alert_method() {
    	
	    	AlertDialog.Builder alert = new AlertDialog.Builder(USER_Login.this);
	    	alert.setMessage(Str_Alert_Msg);
	    	alert.setTitle(Str_Alert_Title);
	    	alert.setPositiveButton("OK", null);
	    	alert.show();
	    	Edit_Frame_Pwd.setText(null);
    	}	
	
    	@Override
    	public void onBackPressed() {
		// TODO Auto-generated method stub
		
		finish();
		
		Intent intent = new Intent(USER_Login.this, CNB_Login.class);
		startActivity(intent);
    	}
}

Step 12 : Open src -> package -> NoticeBoard.java and add following code :

package balaji.cnb;
 
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Bundle;
import android.text.Html;
import android.text.InputType;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.RelativeLayout.LayoutParams;
 
public class NoticeBoard extends Activity {
	
	private SharedPreferences prefs;
	private String prefName = "report";
	
	InputStream is=null;
	String result=null;
	String line=null;
	
	RelativeLayout rl, relative, rl1[];
	LinearLayout linear1;
	ScrollView scroll1;
	
	TextView Text_Owner;
	TextView Text_User[], Text_Date[], Text_Msg[];
	View View_line[];
	CheckBox CB_Admin, CB_HOD, CB_Staff, CB_Student;
	EditText Edit_Msg;
	
	List<String> List_Receiver_Id;
	List<String> List_Out_Se_cnbid, List_Out_Se_uid, List_Out_Date, 
	List_Out_Se_Name, List_Out_Msg, List_Out_MsgId, List_Out_Tag;
	String Se_Name, Se_CNB, Str_Tag, Str_DB_Delete;
	
	String Str_User_Name, Str_User_Id, Str_Msg;
	String Str_ListName, Str_ListTag, Str_ListDt, Str_ListId;
	int Int_cnbid, Int_MsgCount;
	
	String IP_Address;
	
	AlertDialog.Builder alert, alert_update;
	String Str_Pre_Msg;
	int Int_Pre_MsgId;
	List<Integer> List_Pre_TagList;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	super.onCreate(savedInstanceState);
	setContentView(R.layout.noticeboard);
		
	initialise_variables();		
		
	// Get values from DB..
		
	DB_Get_Out_Count();
		
	DB_UserData();
		
	rl1 = new RelativeLayout[Int_MsgCount];
	Text_User = new TextView[Int_MsgCount];
	Text_Date = new TextView[Int_MsgCount];
	Text_Msg = new TextView[Int_MsgCount];
	View_line = new View[Int_MsgCount];
				
	for(int i=0 ; i<Int_MsgCount; i++) {
			
		rl1[i] = new RelativeLayout(NoticeBoard.this);
			
		DB_Get_TagList(List_Out_MsgId.get(i).toString());
		
		DB_Get_SenderData(List_Out_Se_cnbid.get(i).toString(), 
			List_Out_Se_uid.get(i).toString());
		
		Str_ListId = "(" + Se_CNB + " : " + 
			List_Out_Se_uid.get(i).toString() + ")" ;
			
		Str_ListDt = List_Out_Date.get(i).toString();
			
		for(int x=0; x<List_Out_Tag.size(); x++) {
				
			String dummy = List_Out_Tag.get(x);
			Str_Tag = Str_Tag.concat(dummy).concat("  ");
		}
							
		Str_ListName = "<font color = 'red'>" + Se_Name + "</font>" + " : " + 
			List_Out_Msg.get(i).toString() + "<br/><br/>" + 
			"<font color = 'blue'>" + 
						
			Str_Tag +
						
			"</font>" + "<br/><br/>";
		
		Str_Tag = "";
		List_Out_Tag.clear();
			
		rl1[i].setPadding(10, 10, 10, 0);
			
		Text_User[i] = new TextView(NoticeBoard.this);
		Text_User[i].setText(Str_ListId);
		Text_User[i].setTextSize(15);
		RelativeLayout.LayoutParams param_TextUser = new RelativeLayout.LayoutParams
			((int) LayoutParams.WRAP_CONTENT, (int) LayoutParams.WRAP_CONTENT);
		param_TextUser.topMargin = 20;
		Text_User[i].setLayoutParams(param_TextUser);
		rl1[i].addView(Text_User[i]);
 
			
		Text_Date[i] = new TextView(NoticeBoard.this);
		Text_Date[i].setText(Str_ListDt);
		Text_Date[i].setTextSize(15);
		RelativeLayout.LayoutParams param_Text_Date = new RelativeLayout.LayoutParams
			((int) LayoutParams.WRAP_CONTENT, (int) LayoutParams.WRAP_CONTENT);
		param_Text_Date.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
		param_Text_Date.topMargin = 20;
		Text_Date[i].setLayoutParams(param_Text_Date);
		rl1[i].addView(Text_Date[i]);
			
			
		Text_Msg[i] = new TextView(NoticeBoard.this);
		Text_Msg[i].setText(Html.fromHtml(Str_ListName));
		Text_Msg[i].setTextSize(14);
		RelativeLayout.LayoutParams param_Text_UserId = new RelativeLayout.LayoutParams
			((int) LayoutParams.MATCH_PARENT, (int) LayoutParams.WRAP_CONTENT);
		param_Text_UserId.topMargin = 60;
		Text_Msg[i].setLayoutParams(param_Text_UserId);
		rl1[i].addView(Text_Msg[i]);
			
		View_line[i] = new View(NoticeBoard.this);
		RelativeLayout.LayoutParams params_line = new RelativeLayout.LayoutParams
			((int) LayoutParams.MATCH_PARENT, 8);
		params_line.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
		View_line[i].setLayoutParams(params_line);
		View_line[i].setBackgroundColor(Color.MAGENTA);
		rl1[i].addView(View_line[i]);
						
		linear1.addView(rl1[i]);
	}
    }
	
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.noticeboard, menu);
        return true;
    }
	
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
	// TODO Auto-generated method stub
		
	switch(item.getItemId()) {
		
	    case R.id.home :
		finish();
		Intent j = new Intent(NoticeBoard.this, CNB_Login.class);
		startActivity(j);
		return true;
			
	    case R.id.logout :
		finish();
		Intent i = new Intent(NoticeBoard.this, USER_Login.class);
		startActivity(i);
		return true;
				
	    case R.id.update :
		Update_Msg();
		return true;
								
	    case R.id.newmsg : 
		AlertBox_NewMsg();
		return true;
			
	    case R.id.refresh :
		finish();
		Intent intent = new Intent(NoticeBoard.this, NoticeBoard.class);
		startActivity(intent);
	}
		
	return false;
    }
	
    public void Update_Msg() {
		
	// Update Here
		
	alert = new AlertDialog.Builder(NoticeBoard.this);
	alert.setTitle("Update Post");
	relative = new RelativeLayout(NoticeBoard.this);
	relative.setPadding(0, 0, 0, 45);
		
	Edit_Msg = new EditText(NoticeBoard.this);
	Edit_Msg.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
	RelativeLayout.LayoutParams param2 = new RelativeLayout.LayoutParams 
		((int) LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	param2.addRule(RelativeLayout.CENTER_HORIZONTAL);
	param2.topMargin = 40;
	Edit_Msg.setLayoutParams(param2);
		
	CB_Admin = new CheckBox(NoticeBoard.this);
	CB_Admin.setText("Admin");
	CB_Admin.setTextColor(Color.RED);
	RelativeLayout.LayoutParams param4 = new RelativeLayout.LayoutParams 
		((int) LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	param4.leftMargin = 20;
	param4.topMargin = 140;
	CB_Admin.setLayoutParams(param4);
		
	CB_HOD = new CheckBox(NoticeBoard.this);
	CB_HOD.setText("HOD");
	CB_HOD.setTextColor(Color.RED);
	RelativeLayout.LayoutParams param5 = new RelativeLayout.LayoutParams 
		((int) LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	param5.leftMargin = 200;
	param5.topMargin = 140;
	CB_HOD.setLayoutParams(param5);
		
	CB_Staff = new CheckBox(NoticeBoard.this);
	CB_Staff.setText("Staff");
	CB_Staff.setTextColor(Color.GREEN);
	RelativeLayout.LayoutParams param6 = new RelativeLayout.LayoutParams 
		((int) LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	param6.leftMargin = 20;
	param6.topMargin = 220;
	CB_Staff.setLayoutParams(param6);
		
	CB_Student = new CheckBox(NoticeBoard.this);
	CB_Student.setText("Student");
	CB_Student.setTextColor(Color.GREEN);
	RelativeLayout.LayoutParams param7 = new RelativeLayout.LayoutParams 
		((int) LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	param7.leftMargin = 200;
	param7.topMargin = 220;
	CB_Student.setLayoutParams(param7);
		
	Button But_NewMsg = new Button(NoticeBoard.this);
	But_NewMsg.setText("Update");
	RelativeLayout.LayoutParams param3 = new RelativeLayout.LayoutParams 
		(150, LayoutParams.WRAP_CONTENT);
	param3.addRule(RelativeLayout.CENTER_HORIZONTAL);
	param3.topMargin = 330;
	But_NewMsg.setLayoutParams(param3);
		
	DB_Show_Previous_Msg();
		
	Edit_Msg.setText(Str_Pre_Msg);
	for(int i=0; i<List_Pre_TagList.size(); i++) {
			
		switch(List_Pre_TagList.get(i)) {
			
			case 1 :
				CB_Admin.setChecked(true);
				break;
			case 2 :
				CB_HOD.setChecked(true);
				break;
			case 3 :
				CB_Staff.setChecked(true);
				break;
			case 4 :
				CB_Student.setChecked(true);
				break;
		}
	}
		
	But_NewMsg.setOnClickListener(new View.OnClickListener() {
		
	    @Override
	    public void onClick(View v) {
		// TODO Auto-generated method stub
				
		Str_Msg = Edit_Msg.getText().toString();
			
		if(Str_Msg.equalsIgnoreCase("")) {
				
			AlertDialog.Builder alert_error = 
				new AlertDialog.Builder(NoticeBoard.this);
			alert_error.setMessage("Enter Message..");
			alert_error.setTitle("Error");
			alert_error.setPositiveButton("OK", null);
			alert_error.show();
		}
		else {
			List_Receiver_Id.clear();
				
			if(CB_Admin.isChecked()) {
				List_Receiver_Id.add("1");
			}
			if(CB_HOD.isChecked()) {
				List_Receiver_Id.add("2");
			}
			if(CB_Staff.isChecked()) {
				List_Receiver_Id.add("3");
			}
			if(CB_Student.isChecked()) {
				List_Receiver_Id.add("4");
			}
				
			if(List_Receiver_Id.size() == 0) {
					
				AlertDialog.Builder alert_error = 
					new AlertDialog.Builder(NoticeBoard.this);
				alert_error.setMessage("Tag Anyone..");
				alert_error.setTitle("Error");
				alert_error.setPositiveButton("OK", null);
				alert_error.show();
			}
				
			else {
					
				DB_Update_Msg();
			}		
		}
            }
	});
		
	relative.addView(Edit_Msg);
	relative.addView(CB_Admin);
	relative.addView(CB_HOD);
	relative.addView(CB_Staff);
	relative.addView(CB_Student);
	relative.addView(But_NewMsg);
	alert.setView(relative);
	alert.setPositiveButton("Cancel", null);
	alert.show();
    }
	
 
    public void DB_Show_Previous_Msg() {
	// TODO Auto-generated method stub
		
	ArrayList<NameValuePair> Name = new ArrayList<NameValuePair>();
		
	Name.add(new BasicNameValuePair("se_cnbid", String.valueOf(Int_cnbid)));
	Name.add(new BasicNameValuePair("se_uid", Str_User_Id));
		
	try {
		HttpClient http = new DefaultHttpClient();
		HttpPost post = new HttpPost(IP_Address + "DB_Show_Previous_Msg.php");
		post.setEntity(new UrlEncodedFormEntity(Name));
		HttpResponse response = http.execute(post);
		HttpEntity entity = response.getEntity();
		is = entity.getContent();
	}
	catch(Exception e) {
		Log.e("DB_Get_Out_Count", e.toString());
	}
		
	try {
		BufferedReader buffer = new BufferedReader
				(new InputStreamReader(is, "iso-8859-1"), 8);
		
		StringBuilder sb = new StringBuilder();
		while((line=buffer.readLine()) != null) {
			
			sb.append(line +"\n");
		}
		is.close();
		result = sb.toString();
	}
	catch(Exception e) {
		Log.e("DB_Get_Out_Count", e.toString());
	}

	try {
			
		JSONArray jarray = new JSONArray(result);
    		JSONObject jobject = null;
    		
    		Str_Pre_Msg = null;
    		Int_Pre_MsgId = 0;
    		List_Pre_TagList = new ArrayList<Integer>();
    		
    		for(int i=0; i<jarray.length(); i++) {
    			
    			jobject = jarray.getJSONObject(i);
    			
    			Int_Pre_MsgId = jobject.getInt("msg_id");
    			Str_Pre_Msg = jobject.getString("msg");
    			List_Pre_TagList.add(jobject.getInt("re_cndid"));
    		}
	}
	catch(Exception e) {
		Log.e("DB_Get_Out_Count", e.toString());
	}		
    }
	
    public void DB_Update_Msg() {
		
	ArrayList<NameValuePair> Name = new ArrayList<NameValuePair>();
		
	Name.add(new BasicNameValuePair("msg_id", String.valueOf(Int_Pre_MsgId)));
		
	Name.add(new BasicNameValuePair("se_cnbid", String.valueOf(Int_cnbid)));
	Name.add(new BasicNameValuePair("se_uid", Str_User_Id));
	Name.add(new BasicNameValuePair("msg", Str_Msg));
	Name.add(new BasicNameValuePair("recount", String.valueOf(List_Receiver_Id.size())));
	   	
   	for(int i=0; i<List_Receiver_Id.size(); i++) {
	   		
	    String receiverid = "recnbid" + i;
	   		
	    Name.add(new BasicNameValuePair(receiverid, List_Receiver_Id.get(i).toString()));
   	}
		
	try {
		HttpClient http = new DefaultHttpClient();
		HttpPost post = new HttpPost(IP_Address + "DB_Update_Msg.php");
		post.setEntity(new UrlEncodedFormEntity(Name));
		HttpResponse response = http.execute(post);
		HttpEntity entity = response.getEntity();
		is = entity.getContent();
	}
	catch(Exception e) {
		Log.e("DB_Get_Out_Count", e.toString());
	}
		
	try {
		BufferedReader buffer = new BufferedReader
				(new InputStreamReader(is, "iso-8859-1"), 8);
		
		StringBuilder sb = new StringBuilder();
		while((line=buffer.readLine()) != null) {
			
			sb.append(line +"\n");
		}
		is.close();
		result = sb.toString();
	}
	catch(Exception e) {
		Log.e("DB_Get_Out_Count", e.toString());
	}
		
	try {
		JSONObject jobject = new JSONObject(result);
		int code = jobject.getInt("code");
	
		AlertDialog.Builder alert_Update_Report = 
			new AlertDialog.Builder(NoticeBoard.this);
		alert_Update_Report.setTitle("Report");
		alert_Update_Report.setPositiveButton("OK", new OnClickListener() {
				
		    @Override
		    public void onClick(DialogInterface dialog, int which) {
			// TODO Auto-generated method stub
					
			finish();
			startActivity(new Intent(NoticeBoard.this, NoticeBoard.class));
		    }
		});
    		
    		if(code == 1) {
    			
			alert_Update_Report.setMessage("Successfully Updated !!!");
			alert_Update_Report.show();
			clear();
    		}
    		else {
    			
    			alert_Update_Report.setMessage("Try Again..");
    			alert_Update_Report.show();
    			clear();
    		}
	}
	catch(Exception e) {
		Log.e("DB_Get_Out_Count", e.toString());
	}		
    }

    public void AlertBox_NewMsg() {
	// TODO Auto-generated method stub
		
	alert = new AlertDialog.Builder(NoticeBoard.this);
	alert.setTitle("New Post");
	relative = new RelativeLayout(NoticeBoard.this);
	relative.setPadding(0, 0, 0, 45);
	
	Edit_Msg = new EditText(NoticeBoard.this);
	Edit_Msg.setHint("Enter your Message here !!!");
	Edit_Msg.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
	RelativeLayout.LayoutParams param2 = new RelativeLayout.LayoutParams 
		((int) LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	param2.addRule(RelativeLayout.CENTER_HORIZONTAL);
	param2.topMargin = 40;
	Edit_Msg.setLayoutParams(param2);
		
	CB_Admin = new CheckBox(NoticeBoard.this);
	CB_Admin.setText("Admin");
	CB_Admin.setTextColor(Color.RED);
	RelativeLayout.LayoutParams param4 = new RelativeLayout.LayoutParams 
		((int) LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	param4.leftMargin = 20;
	param4.topMargin = 140;
	CB_Admin.setLayoutParams(param4);
	
	CB_HOD = new CheckBox(NoticeBoard.this);
	CB_HOD.setText("HOD");
	CB_HOD.setTextColor(Color.RED);
	RelativeLayout.LayoutParams param5 = new RelativeLayout.LayoutParams 
		((int) LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	param5.leftMargin = 200;
	param5.topMargin = 140;
	CB_HOD.setLayoutParams(param5);
		
	CB_Staff = new CheckBox(NoticeBoard.this);
	CB_Staff.setText("Staff");
	CB_Staff.setTextColor(Color.GREEN);
	RelativeLayout.LayoutParams param6 = new RelativeLayout.LayoutParams 
		((int) LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	param6.leftMargin = 20;
	param6.topMargin = 220;
	CB_Staff.setLayoutParams(param6);
	
	CB_Student = new CheckBox(NoticeBoard.this);
	CB_Student.setText("Student");
	CB_Student.setTextColor(Color.GREEN);
	RelativeLayout.LayoutParams param7 = new RelativeLayout.LayoutParams 
		((int) LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	param7.leftMargin = 200;
	param7.topMargin = 220;
	CB_Student.setLayoutParams(param7);
		
	Button But_NewMsg = new Button(NoticeBoard.this);
	But_NewMsg.setText("Post");
	RelativeLayout.LayoutParams param3 = new RelativeLayout.LayoutParams 
		(150, LayoutParams.WRAP_CONTENT);
	param3.addRule(RelativeLayout.CENTER_HORIZONTAL);
	param3.topMargin = 330;
	But_NewMsg.setLayoutParams(param3);
		
	But_NewMsg.setOnClickListener(new View.OnClickListener() {
		
	    @Override
	    public void onClick(View v) {
		// TODO Auto-generated method stub
				
		Str_Msg = Edit_Msg.getText().toString();
			
		if(Str_Msg.equalsIgnoreCase("")) {
				
			AlertDialog.Builder alert_error = 
				new AlertDialog.Builder(NoticeBoard.this);
			alert_error.setMessage("Enter Message..");
			alert_error.setTitle("Error");
			alert_error.setPositiveButton("OK", null);
			alert_error.show();
		}
		else {
				
			List_Receiver_Id.clear();
			
			if(CB_Admin.isChecked()) {
				List_Receiver_Id.add("1");
			}
			if(CB_HOD.isChecked()) {
				List_Receiver_Id.add("2");
			}
			if(CB_Staff.isChecked()) {
				List_Receiver_Id.add("3");
			}
			if(CB_Student.isChecked()) {
				List_Receiver_Id.add("4");
			}
			
			createNewMessage();
		}
	    }
	});
		
	alert.setNegativeButton("Cancel", null);
	
	relative.addView(Edit_Msg);
	relative.addView(CB_Admin);
	relative.addView(CB_HOD);
	relative.addView(CB_Staff);
	relative.addView(CB_Student);
	relative.addView(But_NewMsg);
	alert.setView(relative);
	alert.show();
    }
 
    public void initialise_variables() {
	// TODO Auto-generated method stub
		
	rl = (RelativeLayout) findViewById(R.id.rl);
	Text_Owner = (TextView) findViewById(R.id.textView1);
	
	prefs = getSharedPreferences(prefName, MODE_PRIVATE);
	Str_User_Name = prefs.getString("uname", "");
		
    	IP_Address = prefs.getString("ip", "http://10.0.2.2/cnb/");
 
	Int_cnbid = prefs.getInt("cnb_id", 0);
	Str_User_Id = prefs.getString("uid", null);
	
	List_Receiver_Id = new ArrayList<String>();
	
	Text_Owner.setText(Str_User_Name);
	
	scroll1 = (ScrollView)findViewById(R.id.scrollView1);
	linear1 = (LinearLayout)findViewById(R.id.linear1);
 
	List_Out_Se_cnbid = new ArrayList<String>();
	List_Out_Se_uid = new ArrayList<String>();
	List_Out_Date = new ArrayList<String>();
	List_Out_Se_Name = new ArrayList<String>();
	List_Out_Msg = new ArrayList<String>();
	List_Out_Tag = new ArrayList<String>();
	List_Out_MsgId = new ArrayList<String>();
	
	Str_Tag = "";
    }
	
    public void DB_Get_Out_Count() {
		
	ArrayList<NameValuePair> Name = new ArrayList<NameValuePair>();
		
	Name.add(new BasicNameValuePair("re_cnbid", String.valueOf(Int_cnbid)));
		
	try {
		HttpClient http = new DefaultHttpClient();
		HttpPost post = new HttpPost(IP_Address + "DB_Get_Out_Count.php");
		post.setEntity(new UrlEncodedFormEntity(Name));
		HttpResponse response = http.execute(post);
		HttpEntity entity = response.getEntity();
		is = entity.getContent();
	}
	catch(Exception e) {
		Log.e("DB_Get_Out_Count", e.toString());
	}
		
	try {
		BufferedReader buffer = new BufferedReader
				(new InputStreamReader(is, "iso-8859-1"), 8);
		
		StringBuilder sb = new StringBuilder();
		while((line=buffer.readLine()) != null) {
			
			sb.append(line +"\n");
		}
		is.close();
		result = sb.toString();
	}
	catch(Exception e) {
		Log.e("DB_Get_Out_Count", e.toString());
	}
		
	try {
		JSONObject jobj = new JSONObject(result);
	
		Int_MsgCount = jobj.getInt("count");
	}
	catch(Exception e) {
		Log.e("DB_Get_Out_Count", e.toString());
	}		
    }

    public void DB_UserData() {
		
	ArrayList<NameValuePair> Name = new ArrayList<NameValuePair>();
	
	Name.add(new BasicNameValuePair("re_cnbid", String.valueOf(Int_cnbid)));
		
	try {
		HttpClient http = new DefaultHttpClient();
		HttpPost post = new HttpPost(IP_Address + "DB_UserData.php");
		post.setEntity(new UrlEncodedFormEntity(Name));
		HttpResponse response = http.execute(post);
		HttpEntity entity = response.getEntity();
		is = entity.getContent();
	}
	catch(Exception e) {
		Log.e("DB_UserData", e.toString());
	}
		
	try {
		BufferedReader buffer = new BufferedReader
				(new InputStreamReader(is, "iso-8859-1"), 8);
		
		StringBuilder sb = new StringBuilder();
		while((line=buffer.readLine()) != null) {
			
			sb.append(line +"\n");
		}
		is.close();
		result = sb.toString();
	}
	catch(Exception e) {
		Log.e("DB_UserData", e.toString());
	}
		
	try {
		JSONArray jarray = new JSONArray(result);
		JSONObject jobj = null;
	
		for(int i=0; i<jarray.length(); i++) {
		
		    jobj = jarray.getJSONObject(i);
		
		    List_Out_Se_cnbid.add(String.valueOf(jobj.getInt("se_cnbid")));
		    List_Out_Se_uid.add(jobj.getString("se_uid"));
		    List_Out_MsgId.add(jobj.getString("msg_id"));
		    List_Out_Msg.add(jobj.getString("msg"));
		    List_Out_Date.add(jobj.getString("dt"));
		}
	}
	catch(Exception e) {
		Log.e("DB_UserData", e.toString());
	}
    }
	
    public void DB_Get_SenderData(String string1, String string2) {
	// TODO Auto-generated method stub
		
	ArrayList<NameValuePair> Name = new ArrayList<NameValuePair>();
	
	Name.add(new BasicNameValuePair("se_cnbid", string1));
	Name.add(new BasicNameValuePair("se_uid", string2));
	
	try {
		HttpClient http = new DefaultHttpClient();
		HttpPost post = new HttpPost(IP_Address + "DB_Get_SenderData.php");
		post.setEntity(new UrlEncodedFormEntity(Name));
		HttpResponse response = http.execute(post);
		HttpEntity entity = response.getEntity();
		is = entity.getContent();
	}
	catch(Exception e) {
		Log.e("DB_Get_SenderData", e.toString());
	}
		
	try {
		BufferedReader buffer = new BufferedReader
				(new InputStreamReader(is, "iso-8859-1"), 8);
		
		StringBuilder sb = new StringBuilder();
		while((line=buffer.readLine()) != null) {
			
			sb.append(line +"\n");
		}
		is.close();
		result = sb.toString();
	}
	catch(Exception e) {
		Log.e("DB_Get_SenderData", e.toString());
	}
	
	try {
		JSONObject jobj = new JSONObject(result);
	    	
		Se_CNB = jobj.getString("se_cnb");
		Se_Name = jobj.getString("se_name");
	}
	catch(Exception e) {
		Log.e("DB_Get_SenderData", e.toString());
	}		
    }
	
    public void createNewMessage() {
		
	if(List_Receiver_Id.size() == 0) {
		
		AlertDialog.Builder alert_error = 
			new AlertDialog.Builder(NoticeBoard.this);
		alert_error.setMessage("Tag Anyone..");
		alert_error.setTitle("Error");
		alert_error.setPositiveButton("OK", null);
		alert_error.show();
	}
		
	else {
		
		InsertNewEntry();
	}		
    }
	
    public void InsertNewEntry() {
		
	ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
	 
   	nameValuePairs.add(new BasicNameValuePair("se_cnbid", String.valueOf(Int_cnbid)));
   	nameValuePairs.add(new BasicNameValuePair("se_uid", Str_User_Id));
   	nameValuePairs.add(new BasicNameValuePair("msg", Str_Msg));
   	nameValuePairs.add(new BasicNameValuePair
		("recount", String.valueOf(List_Receiver_Id.size())));
   	
   	for(int i=0; i<List_Receiver_Id.size(); i++) {
   		
   		String receiverid = "recnbid" + i;
   		
   		nameValuePairs.add(new BasicNameValuePair
			(receiverid, List_Receiver_Id.get(i).toString()));
   	}
	    	
   	try
   	{
   		HttpClient httpclient = new DefaultHttpClient();
   		HttpPost httppost = new HttpPost(IP_Address + "InsertNewEntry.php");
   		httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
   		HttpResponse response = httpclient.execute(httppost); 
   		HttpEntity entity = response.getEntity();
   		is = entity.getContent();		      
   	}
   	catch(Exception e)
   	{
   		Log.e("InsertNewEntry", e.toString());
   	}     
	        
   	try
   	{
   		BufferedReader reader = new BufferedReader
   				(new InputStreamReader(is,"iso-8859-1"),8);
   		StringBuilder sb = new StringBuilder();
   		while ((line = reader.readLine()) != null)
   		{
   			sb.append(line + "\n");
   		}
   		is.close();
   		result = sb.toString();	   		
   	}
   	catch(Exception e)
   	{
   		Log.e("InsertNewEntry", e.toString());
   	}     
	        
   	try
   	{
   		JSONObject json_data = new JSONObject(result);
   		int code=json_data.getInt("code");
	   		
   		AlertDialog.Builder alert_report = 
			new AlertDialog.Builder(NoticeBoard.this);
   		alert_report.setTitle("Report");
   		alert_report.setPositiveButton("OK", new OnClickListener() {
				
		    @Override
		    public void onClick(DialogInterface dialog, int which) {
		        // TODO Auto-generated method stub
					
		        finish();
		        startActivity(new Intent(NoticeBoard.this, NoticeBoard.class));
		    }
		});
	   		
   		if(code==1)
   		{
   			alert_report.setMessage("Successfully Inserted !!!");
   			alert_report.show();
   			clear();
   		}
   		else
   		{
   			alert_report.setMessage("Try Again..");
   			alert_report.show();
   			clear();
   		}
   	}
   	catch(Exception e)
   	{
   		Log.e("InsertNewEntry", e.toString());
   	}
    }
	
    public void clear() {
	// TODO Auto-generated method stub
		
	Edit_Msg.setText(null);
	CB_Admin.setChecked(false);
	CB_HOD.setChecked(false);
	CB_Staff.setChecked(false);
	CB_Student.setChecked(false);
    }
 

    public void DB_Get_TagList(String str) {
	// TODO Auto-generated method stub
		
	ArrayList<NameValuePair> Name = new ArrayList<NameValuePair>();
	
	Name.add(new BasicNameValuePair("msg_id", str));
		
	try {
		HttpClient http = new DefaultHttpClient();
		HttpPost post = new HttpPost(IP_Address + "DB_Get_TagList.php");
		post.setEntity(new UrlEncodedFormEntity(Name));
		HttpResponse response = http.execute(post);
		HttpEntity entity = response.getEntity();
		is = entity.getContent();
	}
	catch(Exception e) {
		Log.e("DB_Get_TagList", e.toString());
	}
		
	try {
		BufferedReader buffer = new BufferedReader
				(new InputStreamReader(is, "iso-8859-1"), 8);
		
		StringBuilder sb = new StringBuilder();
		while((line=buffer.readLine()) != null) {
			
			sb.append(line +"\n");
		}
		is.close();
		result = sb.toString();
	}
	catch(Exception e) {
		Log.e("DB_Get_TagList", e.toString());
	}
		
	try {
		JSONArray jarray = new JSONArray(result);
		JSONObject jobj = null;
	
		List<String> dummy = new ArrayList<String>();
	
		for(int i=0; i<jarray.length(); i++) {
		
			jobj = jarray.getJSONObject(i);
			dummy.add(jobj.getString("re_cndid"));
		}
    		
    		for(int i=0; i<dummy.size(); i++) {
    			
    			 int x = Integer.parseInt(dummy.get(i).toString());
    			
    			switch(x) {
    			
    			case 1 : 
    				List_Out_Tag.add("Admin");
    				break;
    			case 2 : 
    				List_Out_Tag.add("HOD");
    				break;
    			case 3 : 
    				List_Out_Tag.add("Staff");
    				break;
    			case 4 :
    				List_Out_Tag.add("Student");
    				break;
			default :
				List_Out_Tag.add("Others");
				break;
    			}
    		}
    		
    		dummy.clear();
	}
	catch(Exception e) {
		Log.e("DB_Get_TagList", e.toString());
	}
    }
 
    @Override
    public void onBackPressed() {
	// TODO Auto-generated method stub
		
	finish();
		
	Intent intent = new Intent(NoticeBoard.this, USER_Login.class);
	startActivity(intent);
    }
}

Step 13 : Open AndroidManifest.xml and add following code :

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="balaji.cnb"
    android:versionCode="1"
    android:versionName="1.0" >
 
    <uses-sdk
        android:minSdkVersion="3"
        android:targetSdkVersion="15" />
    
    <uses-permission android:name="android.permission.INTERNET"/>
 
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".SampleCodez"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        
        <activity android:name=".NetConnection"></activity>
        
        <activity android:name=".CNB_Login"></activity>
        
        <activity android:name=".USER_Login"></activity>
        
        <activity android:name=".NoticeBoard"></activity>
        
    </application>
 
</manifest>

Step 14 : Open res ->values ->strings.xml and add following code :

<resources>
 
    <string name="app_name">CNB</string>
    <string name="title_activity_main">CNB</string>
 
</resources>

Step 15 : Open www/cnb folder in C Drive create DB_CNB_Frame.php and add following code :

<?php
 
$host='127.0.0.1';
 
$uname='root';
 
$pwd='password';
 
$db="cnb";
 

$con = mysql_connect($host,$uname,$pwd) or die("connection failed");
 
mysql_select_db($db,$con) or die("db selection failed");
 
 
$r=mysql_query("select * from cnb",$con);
 
while($row=mysql_fetch_array($r))
{
	$flag[]=$row;
}
 
print(json_encode($flag));
 
mysql_close($con);
 
?>

Step 16 : Open www/cnb folder in C Drive create DB_ListFrame.php and add following code :

<?php
 
$host='127.0.0.1';
 
$uname='root';
 
$pwd='password';
 
$db="cnb";
 

$con = mysql_connect($host,$uname,$pwd) or die("connection failed");
 
mysql_select_db($db,$con) or die("db selection failed");
 

$key = $_REQUEST['cnbid'];
 
switch($key)
{
 
	case 1 :
 
		$r=mysql_query("select * from admin",$con);
 
		while($row=mysql_fetch_array($r))
		{
			$flag[]=$row;
		}
 
		break;
 
	case 2 :
 
		$r=mysql_query("select * from hod",$con);
 
		while($row=mysql_fetch_array($r))
		{
			$flag[]=$row;
		}
 
		break;
 
	case 3 :
 
		$r=mysql_query("select * from staff",$con);
 
		while($row=mysql_fetch_array($r))
		{
			$flag[]=$row;
		}
 
		break;
 
	case 4 :
 
		$r=mysql_query("select * from student",$con);
 
		while($row=mysql_fetch_array($r))
		{
			$flag[]=$row;
		}
 
		break;
 
}
 
 
print(json_encode($flag));
 
mysql_close($con);
 
?>

Step 17 : Open www/cnb folder in C Drive create DB_Get_Out_Count.php and add following code :

<?php
 
$host='127.0.0.1';
 
$uname='root';
 
$pwd='password';
 
$db="cnb";
 

$con = mysql_connect($host,$uname,$pwd) or die("connection failed");
 
mysql_select_db($db,$con) or die("db selection failed");
 

$recnbid = $_REQUEST['re_cnbid'];
 

$r=mysql_query("select count(*) from header where re_cndid = '$recnbid'",$con);
 
while($row=mysql_fetch_array($r))
{
	$flag['count']=$row[0];
}
 

print(json_encode($flag));
 
mysql_close($con);
 
?>

Step 18 : Open www/cnb folder in C Drive create DB_UserData.php and add following code :

<?php
 
$host='127.0.0.1';
 
$uname='root';
 
$pwd='password';
 
$db="cnb";
 

$con = mysql_connect($host,$uname,$pwd) or die("connection failed");
 
mysql_select_db($db,$con) or die("db selection failed");
 
$recnbid = $_REQUEST['re_cnbid'];
 
$r=mysql_query("select * from header where re_cndid = '$recnbid' order by dt desc",$con);
 
while($row=mysql_fetch_array($r))
{
	$flag[]=$row;
}
 

print(json_encode($flag));
 
mysql_close($con);
 
?>

Step 19 : Open www/cnb folder in C Drive create DB_Get_TagList.php and add following code :

<?php
 
$host='127.0.0.1';
 
$uname='root';
 
$pwd='password';
 
$db="cnb";
 

$con = mysql_connect($host,$uname,$pwd) or die("connection failed");
 
mysql_select_db($db,$con) or die("db selection failed");
 

$msgid = $_REQUEST['msg_id'];
 

$r=mysql_query("select re_cndid from header where msg_id = '$msgid'",$con);
 
while($row=mysql_fetch_array($r))
{
	$flag[]=$row;
}
 

print(json_encode($flag));
 
mysql_close($con);
 
?>

Step 20 : Open www/cnb folder in C Drive create DB_Get_SenderData.php and add following code :

<?php
 
$host='127.0.0.1';
 
$uname='root';
 
$pwd='password';
 
$db="cnb";
 

$con = mysql_connect($host,$uname,$pwd) or die("connection failed");
 
mysql_select_db($db,$con) or die("db selection failed");
 
$secnbid = $_REQUEST['se_cnbid'];
 
$seuid = $_REQUEST['se_uid'];
 
if($secnbid == 1) {
 
	$r=mysql_query("select * from admin where ad_id = '$seuid'",$con);
 
	while($row=mysql_fetch_array($r))
	{
		$flag['se_name']=$row['ad_name'];
	}
 

	$flag['se_cnb'] = 'Admin';
}
 

if($secnbid == 2) {
 
	$r=mysql_query("select * from hod where ho_id = '$seuid'",$con);
 
	while($row=mysql_fetch_array($r))
	{
		$flag['se_name']=$row['ho_name'];
	}
 

	$flag['se_cnb'] = 'HOD';
}
 

if($secnbid == 3) {
 
	$r=mysql_query("select * from staff where stf_id = '$seuid'",$con);
 
	while($row=mysql_fetch_array($r))
	{
		$flag['se_name']=$row['stf_name'];
	}
 

	$flag['se_cnb'] = 'Staff';
}
 

if($secnbid == 4) {
 
	$r=mysql_query("select * from student where std_id = '$seuid'",$con);
 
	while($row=mysql_fetch_array($r))
	{
		$flag['se_name']=$row['std_name'];
	}
 
	$flag['se_cnb'] = 'Student';
}
 

print(json_encode($flag));
 
mysql_close($con);
 
?>

Step 21 : Open www/cnb folder in C Drive create DB_Show_Previous_Msg.php and add following code :

<?php
 
$host='127.0.0.1';
 
$uname='root';
 
$pwd='password';
 
$db="cnb";
 

$con = mysql_connect($host,$uname,$pwd) or die("connection failed");
 
mysql_select_db($db,$con) or die("db selection failed");
 
$secnbid = $_REQUEST['se_cnbid'];
 
$seuid = $_REQUEST['se_uid'];
 
$r=mysql_query("select * from header where se_cnbid = '$secnbid' and se_uid = '$seuid'",$con);
 
while($row=mysql_fetch_array($r))
{
	$msg['msgid']=$row['msg_id'];
}
 
$msgid = $msg['msgid'];
 

$r = mysql_query("select * from header where msg_id = '$msgid'", $con);
 
while($row = mysql_fetch_array($r)) {
 
	$flag[] = $row;
 
}
 

print(json_encode($flag));
 
mysql_close($con);
 
?>

Step 22 : Open www/cnb folder in C Drive create DB_Update_Msg.php and add following code :

<?php
 
$host='127.0.0.1';
 
$uname='root';
 
$pwd='password';
 
$db="cnb";
 

$con = mysql_connect($host,$uname,$pwd) or die("connection failed");
 
mysql_select_db($db,$con) or die("db selection failed");
 

 
$secnbid = $_REQUEST['se_cnbid'];
 
$seuid = $_REQUEST['se_uid'];
 
$msgid = $_REQUEST['msg_id'];
 
$msg = $_REQUEST['msg'];
 
$recount = $_REQUEST['recount'];
 

 
$r=mysql_query("delete from header where msg_id = '$msgid'",$con);
 

$flag = 0;
 
for($i=0; $i<$recount; $i++) {
 
	$geterror = "recnbid".$i;
 
	$errorid[$i] = $_REQUEST[$geterror];
 
	$er = $errorid[$i];
 
	if($r = mysql_query("insert into header values ('$secnbid', '$seuid', '$msgid', '$msg', '$er', now())", $con)) {
 
		$flag = $flag + 1;
 
	}
}
 

 
if ($flag == $recount) {
 
	$fl['code'] = 1;
}
 
else {
 
	$fl['code'] = 0;
}
 

 
print(json_encode($fl));
 
mysql_close($con);
 
?>

Step 23 : Open www/cnb folder in C Drive create InsertNewEntry.php and add following code :

<?php
 
$host='127.0.0.1';
 
$uname='root';
 
$pwd='password';
 
$db='cnb';
 

$con = mysql_connect($host,$uname,$pwd) or die("connection failed");
 
mysql_select_db($db,$con) or die("db selection failed");
 

 
$secnbid = $_REQUEST['se_cnbid'];
 
$seuid = $_REQUEST['se_uid'];
 
$msg = $_REQUEST['msg'];
 
$recount = $_REQUEST['recount'];
 

if($r=mysql_query("select max(msg_id) as asd from header",$con))
{
 
	while($row=mysql_fetch_array($r))
	{
 
		$msgid = $row['asd'];
	}
 
	$msgid = $msgid + 1;
}
 
else {
 
	$msgid = 1;
}
 

 
$flag = 0;
 
for($i=0; $i<$recount; $i++) {
 
	$geterror = "recnbid".$i;
 
	$errorid[$i] = $_REQUEST[$geterror];
 
	$er = $errorid[$i];
 
	if($r = mysql_query("insert into header values ('$secnbid', '$seuid', '$msgid', '$msg', '$er', now())", $con)) {
 
		$flag = $flag + 1;
 
	}
}
 

 
if ($flag == $recount) {
 
	$fl['code'] = 1;
}
 
else {
 
	$fl['code'] = 0;
}
 

 
print(json_encode($fl));
 
mysql_close($con);
 
?>
 

Step 24 : Our output will be like this :


Output


Output


Output


Output


Output


Output


Output


Output


Output


Output


Output


Output


Output


Output


Output


Output


Output


Output


Output


Output









SHARE THIS PAGE



product 2

product 3

product 4

Feedbacks : balaji.scz@gmail.com