Saturday, 21 January 2017

HIDDEN CONCEPT USING JAVASCRIPT

00:44

HIDDEN CONCEPT USING JAVASCRIPT:
======================================================================
First of all create  table user & insert 10 values :
SQL>
create table  users
(user_id  int,
 first_name varchar(200),
last_name varchar(200),
user_city   varchar(200)
);
(1)WRITE CODE FOR display.php file:
<html>
<head>
<script type="text/javascript">
function update_id(id)
{
     if(confirm('do you want to update'))
     {
        window.location.href='update.php?update_id='+id;
     }
}
</script>
<script type="text/javascript">
function delete_id(id)
{
     if(confirm('Sure To Remove This Record ?'))
     {
        window.location.href='delete.php?delete_id='+id;
     }
}
</script>
</head>
<body>
<?php
mysql_connect("localhost","root","");
mysql_select_db("ajax");
$sql_query="SELECT * FROM users";
$result_set=mysql_query($sql_query);
?>
<table align="center" >
    <tr>
    <th>First Name</th>
    <th>Last Name</th>
    <th>City</th>
    <th>Delete</th>
    </tr>
    <?php
 if(mysql_num_rows($result_set)>0)
 {
  while($row=mysql_fetch_array($result_set))
  {
   ?>
            <tr>
            <td><?php echo $row['user_id']; ?></td>
            <td><?php echo $row['first_name']; ?></td>
            <td><?php echo $row['last_name']; ?></td>
<td align="center"><a href="javascript:update_id(<?php echo $row['user_id']; ?>)"><img src="b_drop.png" alt="UPDATE" /></a></td>
       
            <td align="center"><a href="javascript:delete_id(<?php echo $row['user_id']; ?>)"><img src="b_drop.png" alt="Delete" /></a></td>
            </tr>
            <?php
  }
 }
 else
 {
  ?>
        <tr>
        <th colspan="4">There's No data found !!!</th>
        </tr>
        <?php
 }
 ?>
 </table>
 </body>
 </html>
(2)write code for update.php file:
<html>
<head>
<script type="text/javascript">
function finalupdate_id(id)
{
     if(confirm('do you want to update'))
     {
        window.location.href='finalupdate.php?finalupdate_id='+id;
     }
}
</script>
</head>
<body>
<?php

 if(isset($_GET['update_id']))
{
 $hidden=$_GET['update_id'];
$con =mysql_connect("localhost","root","");
mysql_select_db("ajax",$con);
$sql = "select * from users where user_id='$hidden'";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result))
                {
                                echo '<form action="finalupdate.php" method="post">
                                id <input type="text" name="id"  value="'.$row['user_id'].'">
                                Name <input type="text" name="name"  value="'.$row['first_name'].'">
                                email <input type="text" name="email" value="'.$row['last_name'].'">
                                password<input type="text" name="password" value="'.$row['user_city'].'">';
                               ?>
 
                              <a href="javascript:finalupdate_id(<?php echo $row['user_id']; ?>)"><img src="b_drop.png" alt="finalUPDATE" /></a>
            <?php
                                echo '</form>';


                           
                           
                           
                           
                           
                }
}
?>

</body>
</html>

(3)write code for finalupdate.php file:
<?php

 if(isset($_GET['finalupdate_id']))
{
     echo $_GET['finalupdate_id'];
}


?>


(4)write code  for delete.php file:
<?php

 if(isset($_GET['delete_id']))
{
     echo $_GET['delete_id'];
}




?>

Written by

We are Creative Blogger Theme Wavers which provides user friendly, effective and easy to use themes. Each support has free and providing HD support screen casting.

0 comments:

Post a Comment

PHP Training Mumbai, PHP MySQL Training Mumbai, PHP Course Mumbai, PHP Institute Mumbai

 

© 2013 PHP TRAINING IN MUMBAI BY OM SIR . All rights resevered. Designed by OM SIR

Back To Top