Primo commit: trasferimento del progetto PPEasy

This commit is contained in:
2024-09-18 10:30:50 +02:00
commit eb475f257e
4233 changed files with 1043848 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
<?php
if(isset($_POST['idarticletype']))
{
$idarticletype = $_POST['idarticletype'];
include 'dropdown.php';
$obj = new Dropdown();
$rows = $obj->fetchCharact($idarticletype);
echo json_encode($rows);
}
?>
+84
View File
@@ -0,0 +1,84 @@
<?php
Class Dropdown
{
private $host = 'localhost';
private $username = 'u00wiumd4xnrd';
private $password = 'ukowysga7w5x';
private $dbname = 'dbcov4clvrmrzn';
private $connection;
//establish connection
public function __construct()
{
try
{
$this->connection = new mysqli($this->host, $this->username, $this->password, $this->dbname);
}
catch (Exception $e)
{
echo "Connection error " . $e->getMessage();
}
}
//fetch all country records from database
public function fetchCountry()
{
$data = null;
$query = "SELECT * FROM article_type ORDER BY article_type.name_articletype";
if ($sql = $this->connection->query($query))
{
while ($rows = mysqli_fetch_assoc($sql))
{
$data[] = $rows;
}
}
return $data;
}
//fetch model records from database depend upon country id
public function fetchModel($idarticletype)
{
$data = null;
$query = "SELECT * FROM modelarticle WHERE idarticletype='".$idarticletype."' ";
if ($sql = $this->connection->query($query))
{
while ($rows = mysqli_fetch_assoc($sql))
{
$data[] = $rows;
}
}
return $data;
}
//fetch Charact records from database depend on article type
public function fetchCharact($idarticletype)
{
$data = null;
$query = "SELECT * FROM article_characteristic WHERE idarticletype='".$idarticletype."' ";
if ($sql = $this->connection->query($query))
{
while ($rows = mysqli_fetch_assoc($sql))
{
$data[] = $rows;
}
}
return $data;
}
}
?>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+16
View File
@@ -0,0 +1,16 @@
<?php
if(isset($_POST['country_id']))
{
$country_id = $_POST['country_id'];
include 'dropdown.php';
$obj = new Dropdown();
$rows = $obj->fetchCity($country_id);
echo json_encode($rows);
}
?>
+84
View File
@@ -0,0 +1,84 @@
<?php
Class Dropdown
{
private $host = 'localhost';
private $username = 'solocla';
private $password = '!Massarosa2';
private $dbname = 'cmccopia';
private $connection;
//establish connection
public function __construct()
{
try
{
$this->connection = new mysqli($this->host, $this->username, $this->password, $this->dbname);
}
catch (Exception $e)
{
echo "Connection error " . $e->getMessage();
}
}
//fetch all country records from database
public function fetchCountry()
{
$data = null;
$query = "SELECT * FROM article_type ORDER BY article_type.name_articletype";
if ($sql = $this->connection->query($query))
{
while ($rows = mysqli_fetch_assoc($sql))
{
$data[] = $rows;
}
}
return $data;
}
//fetch model records from database depend upon country id
public function fetchModel($idarticletype)
{
$data = null;
$query = "SELECT * FROM modelarticle WHERE idarticletype='".$idarticletype."' ";
if ($sql = $this->connection->query($query))
{
while ($rows = mysqli_fetch_assoc($sql))
{
$data[] = $rows;
}
}
return $data;
}
//fetch Charact records from database depend on article type
public function fetchCharact($idarticletype)
{
$data = null;
$query = "SELECT * FROM article_characteristic WHERE idarticletype='".$idarticletype."' ";
if ($sql = $this->connection->query($query))
{
while ($rows = mysqli_fetch_assoc($sql))
{
$data[] = $rows;
}
}
return $data;
}
}
?>
+151
View File
@@ -0,0 +1,151 @@
-- phpMyAdmin SQL Dump
-- version 4.6.5.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jul 25, 2021 at 05:24 PM
-- Server version: 10.1.21-MariaDB
-- PHP Version: 5.6.30
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `dynamic_dependent_php_oop`
--
-- --------------------------------------------------------
--
-- Table structure for table `city`
--
CREATE TABLE `city` (
`city_id` int(11) NOT NULL,
`state_id` int(11) NOT NULL,
`city_name` varchar(15) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `city`
--
INSERT INTO `city` (`city_id`, `state_id`, `city_name`) VALUES
(1, 1, 'Vadodra'),
(2, 1, 'Surat'),
(3, 2, 'Pune'),
(4, 2, 'Mumbai'),
(5, 3, 'Angoon'),
(6, 3, 'Aniak'),
(7, 4, 'Abbeville'),
(8, 4, 'Alpine');
-- --------------------------------------------------------
--
-- Table structure for table `country`
--
CREATE TABLE `country` (
`country_id` int(11) NOT NULL,
`country_name` varchar(14) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `country`
--
INSERT INTO `country` (`country_id`, `country_name`) VALUES
(1, 'India'),
(3, 'United States');
-- --------------------------------------------------------
--
-- Table structure for table `state`
--
CREATE TABLE `state` (
`state_id` int(11) NOT NULL,
`country_id` int(11) NOT NULL,
`state_name` varchar(15) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `state`
--
INSERT INTO `state` (`state_id`, `country_id`, `state_name`) VALUES
(1, 1, 'Gujarat'),
(2, 1, 'Maharastra'),
(3, 3, 'Alaska'),
(4, 3, 'Alabama');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `city`
--
ALTER TABLE `city`
ADD PRIMARY KEY (`city_id`),
ADD KEY `state_id` (`state_id`);
--
-- Indexes for table `country`
--
ALTER TABLE `country`
ADD PRIMARY KEY (`country_id`);
--
-- Indexes for table `state`
--
ALTER TABLE `state`
ADD PRIMARY KEY (`state_id`),
ADD KEY `country_id` (`country_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `city`
--
ALTER TABLE `city`
MODIFY `city_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `country`
--
ALTER TABLE `country`
MODIFY `country_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `state`
--
ALTER TABLE `state`
MODIFY `state_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `city`
--
ALTER TABLE `city`
ADD CONSTRAINT `city_ibfk_1` FOREIGN KEY (`state_id`) REFERENCES `state` (`state_id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `state`
--
ALTER TABLE `state`
ADD CONSTRAINT `state_ibfk_1` FOREIGN KEY (`country_id`) REFERENCES `country` (`country_id`) ON DELETE CASCADE ON UPDATE CASCADE;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+137
View File
@@ -0,0 +1,137 @@
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" />
<!-- Bootstrap Bundle with Popper -->
<script src="bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- jQuery library -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<title>Dynamic Dependent Select Box PHP OOP Ajax : Onlyxcodes</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark" style="background-color: #3f51b5;">
<div class="container-fluid">
<a class="navbar-brand" href="https://www.onlyxcodes.com/">Onlyxcodes</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="https://www.onlyxcodes.com/2021/07/dynamic-dependent-select-box-php-oop-ajax.html">Back to Tutorial</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="row">
<div class="col-md-12 mt-5">
<?php
include 'dropdown.php';
$obj = new Dropdown();
$rows = $obj->fetchCountry();
?>
<label class="form-label" style="font-size:20px; font-style:bold;">Select Article Type</label>
<select id="articletype_change" class="form-select form-select-lg mb-3" aria-label=".form-select-lg example">
<option>-- select Article Type --</option>
<?php
if(!empty($rows))
{
foreach($rows as $row)
{
?>
<option value="<?php echo $row['idarticletype']; ?>"><?php echo $row['name_articletype']; ?></option>
<?php
}
}
?>
</select>
<label class="form-label" style="font-size:20px; font-style:bold;">Select Model</label>
<select id="model_change" class="form-select form-select-lg mb-3" aria-label=".form-select-lg example">
<option>-- select Model --</option>
</select>
<label class="form-label" style="font-size:20px; font-style:bold;">Select Characteristic</label>
<select id="charact_result" class="form-select form-select-lg mb-3" aria-label=".form-select-lg example">
<option>-- select Characteristic --</option>
</select>
</div>
</div>
</div>
</body>
</html>
<script>
// country dependent ajax
$(document).on("change","#articletype_change", function(e){
e.preventDefault();
var articletype = $("#articletype_change").val();
$.ajax({
type: "POST",
url: "modelart.php",
dataType: "json",
data: "idarticletype="+articletype,
success: function(response)
{
var modelBody = "";
modelBody = "<option>-- select Model --</option>"
for(var key in response)
{
modelBody += "<option value="+ response[key]['idmodelarticle'] +">"+ response[key]['namemodelarticle'] +"</option>";
$("#model_change").html(modelBody);
}
}
});
});
// state dependent ajax
$(document).on("change","#articletype_change", function(e){
e.preventDefault();
var charact = $("#articletype_change").val();
$.ajax({
type: "POST",
url: "articlecharact.php",
dataType: "json",
data: "idarticletype="+charact,
success: function(response)
{
var charactBody = "";
charactBody = "<option>-- select Characteristic --</option>"
for(var key in response)
{
charactBody += "<option value="+ response[key]['idarticlecharacteristic'] +">"+ response[key]['name_articlecharacteristic'] +"</option>";
$("#charact_result").html(charactBody);
}
}
});
});
</script>
+16
View File
@@ -0,0 +1,16 @@
<?php
if(isset($_POST['idarticletype']))
{
$idarticletype = $_POST['idarticletype'];
include 'dropdown.php';
$obj = new Dropdown();
$rows = $obj->fetchModel($idarticletype);
echo json_encode($rows);
}
?>
+16
View File
@@ -0,0 +1,16 @@
<?php
if(isset($_POST['country_id']))
{
$country_id = $_POST['country_id'];
include 'dropdown.php';
$obj = new Dropdown();
$rows = $obj->fetchState($country_id);
echo json_encode($rows);
}
?>