student table
<?php
//EstablishconnectiontoPostgreSQLdatabase
$conn=pg_connect(“host=localhostdbname=your_database_nameuser=your_username
password=your_password”);
//Checkifconnectionwassuccessful
If(!$conn){
Echo“Connectionfailed.”;
Exit;
}
//Createstudenttable
$query=“CREATETABLEstudent(
RollnoINTEGERPRIMARYKEY,
NameVARCHAR(50)NOTNULL,
ClassVARCHAR(10)NOTNULL
)”;
$result=pg_query($conn,$query);
If(!$result){
Echo“Errorcreatingtable:“.pg_last_error($conn);
Exit;
}else{
Echo“Tablecreatedsuccessfully.<br>”;
}
//Insert5recordsintostudenttable
$insert_query=“INSERTINTOstudent(rollno,name,class)
VALUES(1,‘JohnDoe’,‘10A’),
(2,‘JaneSmith’,‘9B’),
(3,‘BobJohnson’,‘11C’),
(4,‘SarahLee’,‘12D’),
(5,‘TomBrown’,‘8E’)”;
$insert_result=pg_query($conn,$insert_query);
If(!$insert_result){
Echo“Errorinsertingrecords:“.pg_last_error($conn);
Exit;
}else{
Echo“Recordsinsertedsuccessfully.”;
}
//Closedatabaseconnection
Pg_close($conn);
?>