Skip to main content

Featured

Adobe Experience Manager - Create an OSGI Configuration

 In this article, let's create an OSGi configuration, configure it and use it in AEM code. So now let's get started with the creation of an OSGi configuration. Technical details and Assumptions: All the following details are tested in AEM version 6.5.8, Java version 11.0.2 Creation of OSGi configuration: To create an OSGi configuration we need to create an ObjectClassDefinition. I have included a sample OCD configuration, which can be used as a reference to create one. The next step would be to create an interface and an implementation that can help fetch the OSGi configurations.  Interface: Implementation: Let's try to use the OSGi configuration created so far in Models/Servlets. For demonstration purposes, I used AEM Models here, but the same can be implemented in Servlets too. Now that we have created the OSGi configuration. Once building the code, we should be able to see the OSGi configuration in the web console (http://localhost:4502/system/console/configMgr) C...

A Web Application


 A PHP & MYSQLi program to perform Insert, Update, Delete and Display queries on the Data Base.

 The Web Application to Perform Basic operations to manipulate the MYSQLi Database with the basic mysqli queries and with php as server side scripting. Below I have Attached the table structure and the executed outputs for the corresponding queries. And to understand the functionality of these mysqli queries.,

mysqli_connect():

      To connect to the server running MYSQL Database and the syntax is as.,
             mysqli_connect(host,username,password,dbname,port,socket);
 
    

mysqli_query():

   To Execute the query and the perform the operations correspondingly
                   mysqli_query(connection,query,resultmode);

 
  

 mysqli_fetch_array():

       To fetch the result as a array and can be like an array using the column name as a index.              mysqli_fetch_array(result,resulttype);

 

These are some of the commonly used mysql functions the helps in making changes in the Database.
Program:
<?php
    $conn = mysqli_connect("localhost","root","","Gladstone") or die("Invalid database");
   if(isset($_POST['insert'])){
    $studname = $_POST['studname'];
    $subname = $_POST['subname'];
    $marks = $_POST['marks'];
    $sql = "INSERT INTO `stud_db`(`studname`, `subname`, `marks`) VALUES ('$studname','$subname',$marks)";
    $res = mysqli_query($conn,$sql);
            if($res){
                echo "Data Inserted";
            }
            else{
                echo "Data not Inserted";
            }
}
if(isset($_POST['update'])){
    $stname = $_POST['stname'];
    $uname = $_POST['usubname'];
    $umarks = $_POST['umarks'];
    $sql = "UPDATE `stud_db` SET `marks`= $umarks WHERE `studname` = '$stname' and `subname` = '$uname'";
    $res = mysqli_query($conn,$sql);
            if($res){
                echo "Data Updated";
            }
            else{
                echo 'Not inserted';
            }
}
if(isset($_POST['delete'])){
    $dstname = $_POST['dstname'];
    $dsub = $_POST['dsub'];
    $sql = "DELETE FROM `stud_db` WHERE `studname` = '$dstname' and `subname` = '$dsub'";
    $res = mysqli_query($conn,$sql);
            if($res){
                echo "Data Deleted";
            }
            else{
                echo 'Data not Deleted';
            }
}
?>
<!DOCTYPE html>
<html>
<head>
<title> Student Data Base</title>
<!-- Bootstrap inclusion -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
    <div class="row">
        <div class="jumbotron"style="text-align:center;">
            Student Mark Entry System
        </div>
    </div>
    <div class ="row">
    <div class ="col-lg-4">
    <label><h1>
    To Insert</h1>
    </label>
<!-- Insert Form -->
    <form action="" method="post" class = "form-vertical">
    <table>
    <tr>
    <th>
    <label>Student Name</label></th><td><input type ="text" name ="studname" class="form-control"required/></td></tr>
    <tr>
    <th>
    <label>Subject Name</label></th><td><select name ="subname" class = "form-control"/><option value="English">English</option><option value = "Tamil">Tamil</option></select></td></tr>
    <tr>
    <th>
    <label>Marks</label></th><td><input type = "number" name ="marks" class = "form-control"required/></td></tr>
    <tr>
    <td colspan = "2">
    <input type ="submit" name = "insert" value = "Insert" class = "form-control"/></td></tr>
    </table>
    </form>
    </div>
    <div class ="col-lg-4">
    <label><h1>Update</h1></label>
<!-- Update Form -->
    <form action ="" method ="post" class = "form-vertical">
    <table>
    <tr>
    <th>
    Student Name</th>
    <td><input type="text" name ="stname" class = "form-control"required/></td></tr>
    <tr>
    <th>
    Subject name</th>
    <td>
    <select name ="usubname" class = "form-control"/><option value="English">English</option><option value = "Tamil">Tamil</option></select></td></tr>
        <tr>
    <th>
    Marks</th>
    <td>
    <input type ="number" name ="umarks" class = "form-control" required/></td></tr>
    <tr>
    <td colspan = "2">
    <input type ="submit" name ="update" value = "Update"class ="form-control" /></td></tr>
    </table>
    </form>
    </div>
    <div class ="col-lg-4">
    <label><h1>Delete</h1></label>
<!-- Delete Form -->
    <form action = "" method = "post" class = "form-vertical">
    <table>
    <tr>
    <th>Student Name</th><td><input type = "text" name = "dstname" class = "form-control"/></td></tr>
    <tr>
    <th>Subject Name</th><td><select name ="dsub" class = "form-control"/><option value="English">English</option><option value = "Tamil">Tamil</option></select></td>
    </tr>
    <td colspan = "2">
    <input type ="submit" name ="delete" value = "Delete"class = "form-control"/>
    </div>
    </div>
    <div class ="row">
    <div class = "col-lg-12">
    <label><h1 style="text-align:center;">View</h1></label>
<!-- Display form -->
    <form action ="" method ="post"class ="form-vertical">
    <input type ="submit" name ="view" value = "View ALL"class ="form-control"/>
    </form>
<?php
if(isset($_POST['view'])){
    $i = 1;
    ?>
    <table>
    <thead>
    <th>
    Student Name</th>
    <th>
    Subject Name</th>
    <th>Marks</th>
    </thead>
    <tbody>
    <?php
    $sql = "SELECT * FROM `stud_db` ";
    $res = mysqli_query($conn,$sql);
    while($rest = mysqli_fetch_array($res)){
        ?>
        <td>
        <?php echo $rest['studname'];?></td>
        <td>
        <?php echo $rest['subname'];?></td>
        <td>
        <?php echo $rest['marks'];?></td>
        <?php
        $i = $i + 1;
    }
    ?>
    </tbody>
    </table>
    <?php
}
?>   
</div>
    </div>
</div>
</body>
</html>
Table Structure:
 
Output:
Insert:
 
 
Update:


  Delete:


Display:



Comments

Popular Posts