Tuesday 23 April 2013

CRUD operation using checkbox in PHP


<!--jquery for check box selecting  -->
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
$(document).ready(function ()
{
$('#d').click(function()
{
if (this.checked==true)
{
$('input[name="a[]"]').prop('checked', true);
}
if (this.checked==false)
{

$('input[name="a[]"]').prop('checked', false);
}
});
});
</script>
<!--new registeration form -->
Register here !!
<form action="" method="post">
username : <input type="text" name="uname"/></br>
password : <input type="password" name="pas"/></br>
Postion  :<input type="text" name="pos"/></br>
<input type="submit" value="register" name="reg"/>
</form>
<!--new chk box editing-->
<?php
$cn=mysql_connect("localhost","root","123");
mysql_select_db("hotel",$cn);
$wue=mysql_query("select * from user");
echo '<form action="" method="post">';
?>
<!--Displaying db values with check box-->
<table>

<tr>
<td><input type="checkbox" name="act" value="" id="d"></td>
<td>ID</td>
<td>USERNAME</td>
<td>POSITION</td>
</tr>
<?php
while($row=mysql_fetch_array($wue))
{
?>
<tr>
<td>
<input type="checkbox" name="a[]" value="<?php echo $row['user_id'];?>"></td>
<?php<
echo '<td>'.$row['user_id'].'</td>';
echo '<td>'.$row['username'].'</td>';
echo '<td>'.$row['position'].'</td>';
echo '</tr>';
}
?>
</table>
<?php
echo '<input type="submit" name="subval" value="edit"/>'.'<input type="submit" name="subdelete" value="delete"/>'.'</form>';
//check box selected value will be displayed in text box
if(isset($_POST['subval']))
{
$ar=$_POST['a'];
echo '<form action="" method="post">';
foreach($ar as $ty)
{
$ru=mysql_query("select * from user where user_id='$ty'");
$ew=mysql_fetch_array($ru);
?>
username :<input type="text" value="<?php echo $ew['username'];  ?>" name="name<?php echo $ty ?>"/>
Position :<input type="text" value="<?php echo $ew['position']; ?>" name="pos<?php echo $ty ?>"/>
<input type="hidden" name="id[]" value="<?php echo $ew['user_id']; ?>">
</br>
<?php
}
echo '<input type="submit" name="subupdate" value="update"/>'.'</form>';
}
//update the text box value after editing
if(isset($_POST['subupdate']))
{
$u=$_POST['id'];
foreach($u as $i)
{
$updt=mysql_query("update user set username='".$_POST['name'.$i]."' , position='".$_POST['pos'.$i]."' where user_id='$i'");
if($updt)
{
echo '<script>window.location=""</script>';
}
}
}
//delete the selected values by using check box
if(isset($_POST['subdelete']))
{
$uio=$_POST['a'];
foreach($uio as $yu)
{
$delt=mysql_query("delete from user where user_id='$yu'");
if($delt)
{
echo '<script>window.location=""</script>';
}
}
}
if(isset($_POST['reg']))
{
$insr=mysql_query("insert into user ( `username`, `password`, `position`) values('".$_POST['uname']."','".$_POST['pas']."','".$_POST['pos']."')");
if($insr)
{
echo '<script>window.location=""</script>';
}
}
?>

OUTPUT:
Download

Monday 22 April 2013

how to display Facebook Likes in Your Web-site / blog

Step 1: go to this link
https://developers.facebook.com/docs/reference/plugins/like/

Step 2:
Paste your fb page url


Step 3:
press get code button u ll get code preview like this

Step 4:
copy and Paste the code [html-5 given in above prev image]
in your web page
note: paste the given code before body tag
like
<html>
<head>
<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=433000033432471";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-like" data-href="http://www.facebook.com/akblog28" data-send="true" data-width="450" data-show-faces="true"></div>
<head>
<body>
</html>
Step 5:
Click save and see your web page
note : this code will run only in Ftp server this code not supported to localhost like [wamp,lamp,mamp]

Step 6:
Finally u got output like this

Sunday 21 April 2013

Steps To become a Programmer


HOW TO BECOME A PROGRAMMER :
Becoming a programmer is a Advancing process that builds up your skills day by day and year by year, and programming can be fun and rewarding (mentally, spiritually and financially). This guide does not promise to give a magically easy way to becoming a programmer, and the ordering of the steps is not sacred, but you'll get a general outline of how to become a programmer in one of the modern programming fields.


Step 1 :
  Take the preliminary course


Step 2:
Learn Database concepts such as tables,views,triggers,procedures
you can learn any simple database packages, such as
-Msaccess
-Mssql
-Mysql
this are all good database to learn and database are commonly accessed by sql queries

Step 3: 
Decide what programming you want to be
-web programmer
-Desktop Application programmer
    -Operating system (OS) oriented programmer
    -Platform-independent programmer
-Distributed applications programmer
-Library/platform/framework/core programmer
-System programmer
   -Kernel programmer
   -Driver programmer
   -Compiler programmer
-Programming scientist

Step 4:
Learn the technologies and programming languages related to your programming field of choice.

Step 5:
Do projects from what are the technologies u learnt , be strong in that

Step 6:
Learn advanced concepts day by day and implement it .



Saturday 20 April 2013

want a mind sharpness, 10 things to do it !


Exercise
Book Reading
Eat Healthy food
Maintain good posture
Sleep well
Do painting,drawing and do some doodle works
Listen to Music
Learn something new
Puzzle solve
Do Blogging 

Friday 19 April 2013

Login with google


First go to
https://code.google.com/apis/console/?pli=1

you will get

do like this

After that create outh

please give details 

after that go to index.php 
########## Google Settings.. Client ID, Client Secret #############
$google_client_id  = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';  //give your client id
$google_client_secret  = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx';    //give ur client secret id
$google_redirect_url  = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx';    //give redirect url
$google_developer_key  = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';//give developer key


########## MySql details (Replace with yours) #############
$db_username = ""; //Database Username
$db_password = ""; //Database Password
$hostname = "localhost"; //Mysql Hostname
$db_name = ''; //Database Name
//please made change all info given above and use it !! 


Download

Login with facebook And twitter


In Dbconfig.php : 
<?php
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'dbusername');
define('DB_PASSWORD', 'dbpassword');
define('DB_DATABASE', 'databasename');
$connection = mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD) or die(mysql_error());
$database = mysql_select_db(DB_DATABASE) or die(mysql_error());
?>


In fbconfig.php:

<?php
define('APP_ID', 'xxxxxxxxxxxxxxxxxx');//add your App id
define('APP_SECRET', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx');//add your App secret id
?>

in twconfig.php
<?php
define('YOUR_CONSUMER_KEY', 'xxxxxxxxxxxxxxxxxxxxxxxxxx');//add your twitter consumer key
define('YOUR_CONSUMER_SECRET', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');//add your consume secret key 
?>

in logintwitter.php
$request_token = $twitteroauth->getRequestToken('http://redirect url');


Download

Thursday 18 April 2013

Display number of Files in a Folder using PHP

<?php
   $path = "d://songs/2013 songs";
   // Open the folder
   $dir_handle = @opendir($path) or die("Unable to open $path");
   // Loop through the files
   while ($file = readdir($dir_handle))
   { 
    echo "<a href=\"$file\">$file</a><br />";
   }
   closedir($dir_handle);
?>

Download

Wednesday 17 April 2013

ANDROID VERSION STATISTICS In 2013




ANDROID VERSION 4.2 [ jelly bean ]

Android 4.2 jelly bean have greater than the speed and capacity while comparing to Android 4.1 and they include all the features like Photo Sphere and a completely redesigned camera app, new Gesture Typing keyboard, Google Now with all new cards, and much more.

Features : 
  • Everything in Jelly Bean feels fast, fluid, and smooth. Moving between home screens and switching between apps is effortless, like turning the pages of a book.
  • Jelly Bean improves performance throughout the system, including faster orientation changes, quicker switching between recent apps, and smoother and more consistent rendering across the system through vsync and triple buffering.
  • Jelly Bean has more reactive and uniform touch responses, and makes your Android device even more responsive by boosting your device’s CPU instantly when you touch the screen, and turns it down when you don’t need it to improve battery life.

     ANDROID STATISTICS :




Friday 12 April 2013

Windows 8 Merits and Demerits




Advantages / Pros:


1. Anticipation for the touch screen
Windows 8, the interface dubbed Metro, is really Anticipate for touch interface with Windows Phone Vogue form.

2. Supports ARM chip
Windows 8 supports devices using ARM chips Framework. Windows 8   conventional  add to the reach of Windows 8 in the tablet arena, given that most currently available tablets using ARM chips. 3.Booting time will be shorter while comparing to previous windows version. Windows 8 will takes only 8 seconds to boot up.

4. Windows 8 does not require a PC upgrade User not need to upgrade the pc requirements , According to Microsoft, both windows 7 and 8 will run in 1GB RAM and Atom processor.

5. Windows app store windows 8 having their own App store called windows store. Windows Store provides a wide range of applications that are optimized for Windows 8. 6. Windows 8 Supports NFC (Near Field Communications)
Windows 8 will support NFC, a technology that their role, among others for financial transactions digitally. Windows 8 tablet taking was likely to automatically include this feature. 


Disadvantages / Cons:


1. Overlap between Metro UI and Aero UI.
Developers find the constant change that occurs between the tile-based Metro UI and glossy Aero UI. It is considered without reasonable and very confusing. Switching from chute applications and desktop applications is very difficult. 


 2. There is no option to turn tiles into icons. The smallest size of the tiles, zoom is still too big. When we install a lot of applications will then screen the chute will look chaotic.

3. It is difficult to move between screens. The absence of such a function Alt-Tab while working with the desktop and keyboard to switch from one app to another app might be a very difficult thing. Instead, on the Windows 8 Metro UI we can not use the pointer or finder to put the screen on the left side and drag. It sounds so trivial, but problems will arise when we are working with many applications. There is no quick and easy way to switch between applications. If you move the mouse to the left then the icon will pops up. And if it is not right then we have to click several times, or try again.


 4. chute multitasking. If my friend uses Metro application (for tablets) in Windows 8, the screen will display two applications are lined. For starters it would not be a big deal. But for advanced users, the ability of Metro to multitasking just for the two applications is a fatal weakness.

 5.chute. Metro is able to work well on tablets but the UI is not very compatible when used on the desktop. Hard to do for my friend who use Notebook. So that by default Windows 8 could not boot to the Metro UI. In other words, Microsoft needs to provide kill-switch to turn off the Metro UI. 

 6. Flash content on the Tablet PC. Apparently Microsoft is deliberately making Windows 8 can not support Flash content on Tablet PC. The reason Microsoft is doing this is to save battery Tablet. It also can protect our privacy and enhance security Tablet. This is because in some applications, and other electronic devices, the use of Flash content even cause data damage or crash. 

Thursday 11 April 2013

jQuery-Php for selecting all checkbox by clicking one checkbox

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
$(document).ready(function () 
{
$('#d').click(function()
{
if (this.checked==true)
{
$('input[name="vehicle[]"]').prop('checked', true);
}
if (this.checked==false)
{
$('input[name="vehicle[]"]').prop('checked', false);
}
});
});
</script>
<form action="" method="post">
<input type="checkbox" name="df" value="Bike" id="d">click to select all<br>
<input type="checkbox" name="vehicle[]" value="scooter">scooter<br>
<input type="checkbox" name="vehicle[]" value="suzuki">suzuki<br>
<input type="checkbox" name="vehicle[]" value="yamaha">yamaha<br>
<input type="checkbox" name="vehicle[]" value="honda">honda<br>
<input type="checkbox" name="vehicle[]" value="Car">car
<input type="submit" value="submit" name="sub"/>
</form>
<?php
if(isset($_POST['sub']))
{
$a=$_POST['vehicle'];
print_r($a);
}
?>

Download

Monday 8 April 2013

Display all the contents in database using table view in codeigniter (its just seen like asp.net grid view )

base.php(controller folder) :

<?php
        class base extends CI_Controller {
 function __construct()                            /*loading constructor*/
 {
  parent::__construct();
                
 }
function you()
        {
  $data['name']=$this->name;
                $data['color']=$this->color;
 }
 public function getall()                            /*loading model*/
 {
  $this->load->model('empl');
  $data['query']=$this->empl->employeey(); //loading model function
  
 }
 public function index()
        {
  $pageinfo['title']="this is my title";
                $pageinfo['heading']="MY HEADING";
                $this->load->view('base_view',$pageinfo);
  $this->getall();   
 }
        }
?>
empl.php(model folder)
<?php
class empl extends CI_Model
{
 function __construct()
 {
  parent::__construct();
  $this->load->database();
  $this->load->library('table');
 }
 function employeey()
 {
  $tmpl = array (
'table_open' => '<table border="1" cellpadding="4" cellspacing="1" width="30%"
align="center" bordercolor="#CCCCCC">',
'row_alt_start' => '<tr bgcolor="lightgrey" >',
 );  
  $this->table->set_template($tmpl);
  //$this->db->where('id','3');         //used for where condition
  $query=$this->db->get('sample');    //used for selecting all the values
  $header = array('emp id', 'first name');
  $this->table->set_heading($header);
  echo $this->table->generate($query);
  
 }
}
?>
base_view.php(view folder)
create one file name base_view.php in view folder for displaying contents

Database
use database name sample
set fields-> id(int(4)), name(varchar(50))
in attachment does not contain database u want to create it by using previous instructions
Download

Saturday 6 April 2013

Reading and displaying all the values from database using code igniter

base.php(controller folder) :

<?php
        class base extends CI_Controller {
 function __construct()                            /*loading constructor*/
 {
  parent::__construct();
                
 }
function you()
        {
  $data['name']=$this->name;
                $data['color']=$this->color;
 }
 public function getall()                            /*loading model*/
 {
  $this->load->model('empl');
  $data['query']=$this->empl->employeey(); //loading model function
  $this->load->view('employee',$data);
 }
 public function index()
        {
  $pageinfo['title']="this is my title";
                $pageinfo['heading']="MY HEADING";
                $this->load->view('base_view',$pageinfo);
  $this->getall();   
 }
        }
?>
empl.php(model folder)
<?php
class empl extends CI_Model
{
 /*function __construct()
 {
  parent::__construct();
 }*/
 function employeey()
 {
  $this->load->database();
  //$this->db->where('id','3');         //used for where condition
  $query=$this->db->get('sample');    //used for selecting all the values
  return $query->result();
 }
}
?>
employee.php(view folder)
<?php
foreach($query as $rows) 
{
echo $rows->id;
echo $rows->name;
//echo $rows->number;
echo "<br>";
} 
?>
Database
use database name sample
set fields-> id(int(4)), name(varchar(50))
in attachment does not contain database u want to create it by using previous instructions

Download