Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

<%@page import="java.sql.

DriverManager"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<% //Making the database connection
String id = request.getParameter("id");
String driver = "com.mysql.jdbc.Driver";
String connectionUrl = "jdbc:mysql://localhost:3306/";
String database = "medicinestocks";
String userid = "root";
String password = "MyNewPass";
try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
%>
<%
try{
connection = DriverManager.getConnection(connectionUrl+database, userid,
password);
statement=connection.createStatement();
String sql ="select * from medicinestockstable where id="+id;
resultSet = statement.executeQuery(sql);
while(resultSet.next()){
%>
<!DOCTYPE html>
<html>
<head>
<title>Update details</title>
<meta charset="ISO-8859-1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Importing W3Css libaries -->
<link rel="stylesheet" href="../css/update.css">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://www.w3schools.com/lib/w3-colors-
metro.css">
<link rel="stylesheet" href="https://www.w3schools.com/lib/w3-colors-
2020.css">
<link rel="stylesheet" href="https://www.w3schools.com/lib/w3-colors-
ios.css">
<link rel="stylesheet" href="https://www.w3schools.com/lib/w3-colors-
flat.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?
family=Ropa+Sans">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-
awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<div class="w3-container w3-animate-right">
<br>
<div class="w3-card-4">
<div class="w3-container w3-ios-blue">
<h3 style="font-family:Helvetica;">Update Here &nbsp; <i class="fa fa fa-
refresh w3-spin "></i></h3>
</div>
<!-- Form -->
<div class="w3-container ">
<form method="post" action="update-process.jsp" class="w3-container"
style="font-family:Helvetica; font-size:14.2px;">
<input type="hidden" name="id" value="<%=resultSet.getString("id") %>">
<br><br>

<label>Enter Medicine Stock Id</label><br>


<input type="text" class="w3-input" name="mid" value="<
%=resultSet.getString("idMedicineDb") %>">
<br>

<label>Enter Medicine name</label><br>


<input type="text" class="w3-input" name="mname" value="<
%=resultSet.getString("nameMedicineDb") %>">
<br>

<label>Enter Medicine quantity</label><br>


<input type="text" class="w3-input" name="mquantity" value="<
%=resultSet.getString("quantitymedicineDb") %>">
<br>

<label>Enter Medicine price</label><br>


<input type="text" class="w3-input" name="mprice" value="<
%=resultSet.getString("priceMedicineDb") %>">

<label>Enter date</label><br>
<input type="date" class="w3-input" name="mdate" value="<
%=resultSet.getString("dateMedicineDb") %>">

<br>
<input type="submit" value="Update" class="w3-btn w3-2020-mosaic-blue"
style="border-radius:5px;">
<br>
</form>
<br>
</div>
<%
} //Closing the database connection
connection.close();
} catch (Exception e) {
e.printStackTrace();
}
%>
</div>
</div>
</body>
</html>

You might also like