Dynamic Dependent Dropdown Using PHP and MySQLi
Dynamic Dependent Dropdown Using PHP and MySQLi
(3, 'PHP', 'PHP is a server scripting language, and a powerful tool for making dynamic and interactive', 2,
1),
(4, 'C Language', 'C is a general-purpose, high-level language that was originally developed by Dennis M.
Ritchie', 2, 1),
(6, 'Laravel', 'Laravel is a PHP web application framework with expressive, elegant syntax, aiming to take
the pain out of web development.', 5, 2),
(7, 'CodeIgniter', 'CodeIgniter is a powerful PHP framework with a small footprint, built for those who
required a simple, yet elegant toolkit', 5, 2),
(8, 'CakePHP', 'CakePHP enables you to build web applications faster, using code generation features to
rapidly build prototypes.', 5, 2),
(9, 'Symfony', 'Symfony is a PHP framework to speed up the creation and maintenance of your web
applications.', 5, 2),
(12, 'Softglobe.net', 'The Web development,Android development and Technology Company in India',
10, 3);
2. Database Configuration
<?php
$con = mysqli_connect("localhost","root","","technopoints");
// Check connection
if (mysqli_connect_errno())
?>
<?php
require 'dbconfig.php';
$pmenu = $_GET["pcat"];
if (isset($_POST['submit'])) {
if (isset($_POST['ccat'])) {
$pmenu = $_POST['pcat'];
$cmenu = $_POST['ccat'];
}
?>
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function autoSubmit()
with (window.document.form) {
if (pcat.selectedIndex === 0) {
window.location.href = 'dependentdropdown.php';
} else {
window.location.href = 'dependentdropdown.php?pcat=' +
pcat.options[pcat.selectedIndex].value;
</script>
</head>
<?php
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
<p class="bg">
<?php
$result = mysqli_query($con,$sql);
?>
</select>
</p>
<?php
$result = mysqli_query($con,$sql);
$num = mysqli_num_rows($result);
if ($num > 0) {
?>
<p class="bg">
<?php
//SUBCATEGORY stared
?>
</select>
</p>
<?php
?>
</form>
<h3><?php
if
(isset($_POST['submit'])) {
$result2 = mysqli_query($con,$qry2);
$row2 = mysqli_fetch_array($result2,MYSQLI_ASSOC);
echo implode($row2);
?></h3>
</div>
<center></body>
</html>
input[type=text] {
width: 95%;
margin: 3px 0;
display: inline-block;
border-radius: 4px;
box-sizing: border-box;
input[type=submit]{
color: black;
.styled-select.slate select {
font-size: 16px;
height: 34px;
width: 268px;
body {
background-color:rgba(100,200,255,0.5);
input[type=submit]:hover {
align:center;
background-color: #555555;
color: white;
Output