Source Code of Create, Read, Update and Delete in Php.
Source code of config.php
<?php
$conn = mysqli_connect(“localhost”, “root”, “”, “northwind”) OR die(“CNC”);
?>
Showcustomers.php
<?php
include ‘config.php’;
$sqlshow = “SELECT `CustomerID`, `CompanyName`, `ContactName`, `ContactTitle` FROM `customers` “;
$results = mysqli_query($conn, $sqlshow);
echo “<table border=’1′ width=’100%’><tr><th>ID</th> <th>CompanyName</th> <th>ContactName</th> <th>ContactTitle</th></tr>”;
foreach($results as $result){
?>
<tr>
<td><?php echo $result[‘CustomerID’];?></td>
<td><?php echo $result[‘CompanyName’];?></td>
<td><?php echo $result[‘ContactName’];?></td>
<td><?php echo $result[‘ContactTitle’];?></td>
<td>
<a href=”editcustomers.php?cust_id=<?php echo $result[‘CustomerID’];?>”>Edit</a>
</td>
</tr>
<?php
}
echo “</table>”;
?>
Editcustomers.php
<?php
include ‘config.php’;
$custid = $_GET[‘cust_id’];
$sqlshow = “SELECT `CustomerID`, `CompanyName`, `ContactName`, `ContactTitle`
FROM `customers`
WHERE CustomerID = ‘$custid’;
“;
$results = mysqli_query($conn, $sqlshow);
foreach($results as $result){
?><form>
<input type=”hidden” name=”contid” value=”<?php echo $_GET[‘cust_id’];?>”><br/>
<input type=”text” name=”cmpname” value=”<?php echo $result[‘CompanyName’];?>”><br/>
<input type=”text” name=”contname” value=”<?php echo $result[‘ContactName’];?>”><br/>
<input type=”text” name=”contitle” value=”<?php echo $result[‘ContactTitle’];?>”><br/>
<input type=”submit” name=”update” value=”Update”>
</form>
<?php
}
echo $_GET[‘cust_id’];
?>
Download Sql from here
https://www.aspsnippets.com/Articles/Download-and-Install-Microsoft-Northwind-Sample-database-in-MySql.aspx

Ankit Srivastava is an IT trainer, technology educator, and digital skills mentor with expertise in programming, data analytics, AI, and software development. He has successfully trained thousands of learners, with more than 10,000 student enrollments on Udemy. His practical teaching approach empowers students and professionals to build in-demand technical skills. Colorstech channel where Ankit posts video tutorials has more than 8000 Subscribers.



