Professional Documents
Culture Documents
Week 9 and Week 10
Week 9 and Week 10
CSM-3371
SESSION 2021-22
3rd Semester
WEEK-9 and 10
Submitted by
Name: SHAHJAHAN
Roll no.: 20MCA25 Remark:
Enrolment no.:GI-1666
WEEK #9
1# Write a PHP program to connect to a database and retrieve data from a table
and show the details in a neat format
▪ Marklist of a student is entered and saved to MySQL table using PHP
▪ Data stored in MySQL table is displayed
Solution:
<?php include("username.php"?>
<!DOCTYPE html>
<html>
<head>
<title> User Name</title>
</head>
<body>
<style>
table, th, td {
th {
text-align:left;
</style>
</head>
<div class="col-lg-12">
<tr>
<th>Name</th>
<th>Enrollment No.</th>
<th>Email ID</th>
<th>Class Name</th>
<th>Physics</th>
<th>Chemistry</th>
<th>Mathematics</th>
<th>Hindi</th>
<th>English</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<?php
$dbhost='localhost';
$dbusername='root';
$dbpass='';
//$dbname='username'
$conn=mysqli_connect($dbhost,$dbusername,$dbpass,$dbname); if(!$conn) {
die("Connection Field" . $conn->connect_error);
{
echo"<tr>";
}
mysqli_close($conn);
?>
</tbody>
</table>
</div>
<?php if(isset($_POST['submit']))
{
$enroll=$_POST['enroll'];
$name=$_POST['name'];
$class=$_POST['class'];
$email=$_POST['email'];
$physics=$_POST['physics'];
$chemistry=$_POST['chemistry'];
$mathematics=$_POST['mathematics'];
$english=$_POST['english'];
$hindi=$_POST['hindi'];
$total=$_POST['total'];
{
echo"<br>Registration Success";
else
{
?>
<script type="text/javascript">
window.location.href=window.location.href;
</script>
</body>
</html>
Before Insert
After Insert
2# Write a PHP code to insert ,delete, select the data from database
<?php include("username.php")
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
name="physics"><br><br>
type="number" name="total"><br><br>
<input type="Submit" name="submit">
<style>
table, th, td {
th, td {
padding: 5px;
th {
text-align:left;
}
</style>
</head>
<div class="col-lg-12">
<thead>
<tr>
<th>Name</th>
<th>Enrollment No.</th>
<th>Email ID</th>
<th>Class Name</th>
<th>Physics</th>
<th>Chemistry</th>
<th>Mathematics</th>
<th>Hindi</th>
<th>English</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<?php
$dbhost='localhost';
$dbusername='root';
$dbpass='';
//$dbname='username'
$conn=mysqli_connect($dbhost,$dbusername,$dbpass,$dbname); if(!$conn) {
$result=mysqli_query($conn,$sql); while($row=mysqli_fetch_assoc($result))
{
echo"<tr>";
mysqli_close($conn);
?>
</tbody>
</table>
</div>
<?php if(isset($_POST['submit']))
$enroll=$_POST['enroll'];
$name=$_POST['name'];
$class=$_POST['class'];
$email=$_POST['email'];
$physics=$_POST['physics'];
$chemistry=$_POST['chemistry'];
$mathematics=$_POST['mathematics'];
$english=$_POST['english'];
$hindi=$_POST['hindi'];
$total=$_POST['total'];
if($result)
echo"<br>Registration Success";
else
}
}
?>
<?php if(isset($_POST['delete']))
"); echo"success";
}
?>
</script>
<?php if(isset($_POST['update']))
?>
</script>
</body>
</html>
Another File
<?php
$dbhost='localhost';
$dbname='username';
$dbusername='root';
$dbpass='';
$mysqli=mysqli_connect($dbhost,$dbusername,$dbpass,$dbname);
?>
Before Updation
After Updation
Before Deletion
After Deletion
<?php
?>
<?php
$dbhost='localhost';
$dbusername='root';
$dbpass='';
$conn=mysqli_connect($dbhost,$dbusername,$dbpass); if(!$conn) {
else
$dbname='username';
$conn1=mysqli_connect($dbhost,$dbusername,$dbpass,$dbname);
} else{
mysql_close($conn); mysql_close($conn1);
?>
WEEK 10
Code:
1. Create a new Window application with name as notepad
2. Add Menu Strip to form1 and set IsMdiContainer property of form1 to
true
3. Set text property of form1 as Notepad
4. Create File menu by adding text at type here textbox.
(File,New ,Open,save,Exit)
5. Create Edit menu by adding text at type here textbox.
(Edit,cut,Copy,Paste,Select
All,Time/date,Clear)
6. Create Format menu by adding text at type here textbox.(Format,font)
7. Add Form2 tp project by clicking Project menu.
8. Add Richtextbox to form2 and set dock property of richtextbox to fill.
9. Add the following code by double clicking File-New Option in
menustrip.
10. Add OpenfileDialog,SaveFileDialog,FontDialog to form1.
Public Class Form1
Public Class Form1
Dim n As Integer
Dim forms(10) As Form2
Dim s As String
Dim s1 As Integer
Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Handles NewToolStripMenuItem.Click
n += 1
forms(n) = New Form2
////// Double click on Edit-Copy option in menu Strip and add the code.
////// Double click on Edit-Paste option in menu Strip and add the code.
txt_card.Text = tot
MsgBox("Payment is deduced from ur account") End If
ElseIf rdo_cash.Checked = False And Rdo_card.Checked = False Then
MsgBox("U must choose payment mode")
End If End Sub
Private Sub rdo_card_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles rdo_card.CheckedChanged
lbl_cardno.Visible = True txt_card.Visible = True
End Sub
Private Sub btn_close_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_close.Click
Me.Close()
End Sub
End Class
Design:
Title of the form: Cafeteria Controls used
Control Name Text
Form1 Form1 Cafeteria
Label1 lbl_tea Tea
Label2 lbl_coffee Coffee
Label3 lbl_total Total amount in RS
Label4 lbl_cardno Enter card No
Label5 lbl_qty Qty
Button1 btn_calculate Calculate
Button2 btn_close Close
Textbox1 txt_tea
Textbox2 txt_coffee
Textbox3 txt_amt
Textbox4 txt_card
Check box1 chk_tea Without sugar
CheckBox2 chk_coffee Cold coffee
Radio Button1 rdo_cash Cash
RadioButtton2 rdo_card Crdit card
GroupBox1
GroupBox2
OUTPUT:
3. Set
the text property of label1 as Select the formatting option and label2 as
Welcome.
4. In
the properties window click on ellipse button beside the nodes option.
This will open a tree node Editor dialog box.
6. Type the text options in the text property. This will set the text of the node
to options.
7. Now select the option node and click on Add Child button to add child
nodes to the parent node Options.
8. Now set the text property of node as Size and add another chilld Format
9. Now add child nodes to size and Format and click ok button.