Posts

Showing posts from 2015

Insert Data in Database through pdo in php..

try {  $db = new PDO('mysql:host=localhost;dbname=idegraphics', 'root', '');  $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);  $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); }catch(PDOException $e) { echo 'ERROR: ' . $e->getMessage(); } $radio=$_POST["radio1"]; $descr=$_POST["descr"]; $yrreg=$_POST["select"]; $carmodel=$_POST["mot"]; $fuel=$_POST["fuel"]; $variant=$_POST["variant"]; try {     $stmt = $db->prepare("insert into motorscustomer(cardetails,registartiondetails,yearofregistation,cardetailsname,fueltype,variantype) values(?,?,?,?,?,?)");     $stmt->execute(array($radio,$descr,$yrreg,$carmodel,$fuel,$variant)); $last_id = $db->lastInsertId();   //  echo "New record created successfully. Last inserted ID is: " . $last_id; }catch(PDOException $e) {     echo 'ERROR: ' . $e->getMessage(); }

Rating Bar in Android.

Image
 rates = (EditText) findViewById(R.id.rates);                         rates.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if(rates.getText().length()>0) { ratingBar.setRating(Float.parseFloat(rates.getText().toString())); rating_val.setText(String.valueOf(rates.getText().toString())); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { } });

Import csv file data in database through PHPExcel.

<?php error_reporting(E_ALL); set_time_limit(0); date_default_timezone_set('Europe/London'); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>PHPExcel Reader Example #01</title> </head> <body> <h1>PHPExcel Reader Example #01</h1> <h2>Simple File Reader using PHPExcel_IOFactory::load()</h2> <?php $connection=mysql_connect("127.0.0.1","root",""); mysql_select_db("idegraphics",$connection); /** Include path **/ set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/'); /** PHPExcel_IOFactory */ include 'PHPExcel/IOFactory.php'; $inputFileName = './sampleData/vmpc.csv'; echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory to identify the format<br />'; $objPHPExcel = PHPExcel_IOFactory::load($inputFileName); $sh

Call Curl in php.

$ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "www.abc.com"); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // grab URL and pass it to the browser curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch);

Google Chart with Database.

Image
<?php include("db.php"); $query = "select * from warehouse"; if ($result = mysql_query($query)) {     {     $rows = array();     $table = array();     $table['cols'] = array(             array('label' => 'Warehouse', 'type' => 'string'),             array('label' => 'Percentage', 'type' => 'number')     );     while ($row =mysql_fetch_array($result)) { $begani=mysql_fetch_array(mysql_query("select sum(stcokprice) from beganinventory where warehouse='$row[2]'")); $a="warehouse"; $b=200;             $temp = array();             $temp[] = array('v' => (string) $row[2]);             $temp[] = array('v' => (int) $begani[0]);             $rows[] = array('c' => $temp);             }    }  } $table['rows'] = $rows; $jsonTable = json_encode($table); ?> <link href="myadminstyle.css" rel="styleshe

Add Texfield in Html Table through Javascript.

<script type="text/javascript"> function addRow(tableID) {         var table = document.getElementById(tableID);         var rowCount = table.rows.length;         var row = table.insertRow(rowCount);         var cell1 = row.insertCell(0);          cell1.innerHTML = rowCount;         var cell2 = row.insertCell(1);         cell2.innerHTML = "<input type='text' name='key[]' style='width:140px;'>";         var cell3 = row.insertCell(2);         cell3.innerHTML = "<input type='text' name='descr[]' style='width:140px;'>";         var cell4 = row.insertCell(3);         cell4.innerHTML = "<input type='text' name='city[]' style='width:140px;'>";         var cell5 = row.insertCell(4);         cell5.innerHTML = "<input type='text' name='address[]' style='width:140px;'>";  var cell6 = row.insertCell(5);         cell6.inner

Edit Data in Database through html Table

 <table cellspacing="0" style="font-size:15px;" width="100%" align="center" id="sl">    <p class="a">Custom Subsidiary</p>  <INPUT type="button" value="Add" onclick="addRow('sl')" style="font-family: 'icomoon';     font-size: 12px;content: \e608;"/>   <tr style="" width="100%">   <th style="border-bottom: black 2px solid;"></th>     <th style="border-bottom: black 2px solid;text-align:left;" valign="left">Key</th>   <th style="border-bottom: black 2px solid;text-align:left;" align="left">Description</th>   <th style="border-bottom: black 2px solid;text-align:left;" align="left">City</th>   <th style="border-bottom: black 2px solid;text-align:left;" align="left">Address</th>

add background image on div.

<div  style="margin-left:0px;color:white;width:100%;background-image:url('images1/menu.jpg');"> Scan </div>

check connection available or not in android.

public static boolean isNetworkAvailable(Context cont) {    ConnectivityManager connectivityManager          = (ConnectivityManager)cont. getSystemService(Context.CONNECTIVITY_SERVICE);    NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();    return activeNetworkInfo != null && activeNetworkInfo.isConnected(); } and check this in- if(isNetworkAvailable(getApplicationContext())) { new Resiter().execute(); } else { Toast.makeText(getApplicationContext(), "Internet Unavailable...Please connect to Internet",3000).show(); }

Match word in String.

String string = "this is Naveen rajput"; String keyword = "Naveen"; Boolean found = Arrays.asList(string.split(" ")).contains(keyword); if(found){       System.out.println("Keyword matched");}

Connection pool in apache tomcat.

Context.xml <?xml version="1.0" encoding="UTF-8"?> <Context antiJARLocking="true" path="/apacheindia"> <Resource name="jdbc/testdb" auth="Container" maxActive="10000" maxIdle="5000" maxWait="60000" username="root" password="root" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3305/indiaswap?autoReconnect=true" logAbandoned="true" removeAbandoned="true" removeAbandonedTimeout="60" type="javax.sql.DataSource" /> </Context> database1.java package Db; import java.sql.DriverManager; import javax.naming.Context; import javax.naming.InitialContext; import javax.sql.DataSource; /**  *  * @author Naveen  */ public class database1 {     private DataSource dataSource;      public DataSource connectit()     {     java.sql.Connection con=null;         try         {              Co

Sending Mail Through Servlet

/*  * To change this license header, choose License Headers in Project Properties.  * To change this template file, choose Tools | Templates  * and open the template in the editor.  */ import Db.databse; import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; import java.sql.Date; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.Properties; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /**  *  * @author Naveen&Jyoti  */ @WebServlet(urlPatterns = {"/Register.action"}) public

BroadcastReceiver in android

Image
package example.readsms; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.telephony.SmsMessage; import android.widget.Toast; public class SmsBroadcastReceiver extends BroadcastReceiver {     public static final String SMS_BUNDLE = "pdus";     public void onReceive(Context context, Intent intent) {         Bundle intentExtras = intent.getExtras();         if (intentExtras != null) {             Object[] sms = (Object[]) intentExtras.get(SMS_BUNDLE);             String smsMessageStr = "";             for (int i = 0; i < sms.length; ++i) {                 SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) sms[i]);                 String smsBody = smsMessage.getMessageBody().toString();                 String address = smsMessage.getOriginatingAddress();                 smsMessageStr += "SMS From: " + address + "\n";  

Read Sms in android.

Image
package example.readsms; import java.net.URI; import java.util.ArrayList; import android.net.Uri; import android.os.Bundle; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.database.Cursor; import android.telephony.SmsMessage; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; public class MainActivity extends Activity { public static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED"; ArrayList<String> list; ArrayAdapter<String> adapter; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activit

check session value is exit or not in jsp.

<% String userName = (String) session.getAttribute("email"); if (null == userName) {    request.setAttribute("Error", "Session has ended.  Please login.");    RequestDispatcher rd = request.getRequestDispatcher("index.jsp");    rd.forward(request, response); } %>

Pagination in jsp.

<%@include file="header.jsp" %> <style> #listings { display:block;   height:30px;   margin:0;   padding:0;   text-align:center;   color: white; background-color: green;   display:inline-block;   line-height:25px;   list-style:none;   margin-right:1px;   padding:0;   text-align:center;   width:30px;   text-decoration:none;   margin-left:2px;   font-size:15px; } #testing { font-size:15px; color:black; } </style> <% int page1;  if (request.getSession(false) == null) { response.sendRedirect("index.jsp");  } user.Methods m=new user.Methods(); String mail=session.getAttribute("email").toString(); String pass=session.getAttribute("pass").toString(); %> <table>     <tr>         <td>&nbsp;</td>         <td>&nbsp;</td>         <td>&nbsp;</td>     </tr>     </table> <table align="center" cellspacing=&

TabLayout in android.

Image
package com.example.savetab; import android.os.Bundle; import android.app.Activity; import android.app.TabActivity; import android.content.Intent; import android.graphics.Color; import android.view.Menu; import android.widget.TabHost; import android.widget.TabHost.TabSpec; public class MainActivity extends TabActivity { TabHost th; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); th=getTabHost(); TabHost.TabSpec spec; Intent intent; intent =new Intent(this, Add.class ); spec=th.newTabSpec("naVEEN").setIndicator("Add Record").setContent(intent); th.addTab(spec); intent =new Intent(this, Listofname.class ); spec=th.newTabSpec("naVEEN").setIndicator("List Of Record").setContent(intent); th.addTab(spec); intent =new Intent(this,ShowonGrid.class); spec=th.newTabSpec("naVEEN").setIndicator("