-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
35019a4
commit 1be8d02
Showing
10 changed files
with
179 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Istruzioni per creare il database e la tabella | ||
|
||
Andare in phpmyAdmin e andare nella voce di menu a tab "SQL". | ||
|
||
1. Creare il DB | ||
|
||
CREATE DATABASE giugno | ||
|
||
2. Andare nel database appena creato e create la tabella | ||
|
||
CREATE TABLE `insiemi` ( | ||
`id` int(11) NOT NULL, | ||
`valore` int(11) NOT NULL, | ||
`insieme` int(11) NOT NULL | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf16; | ||
|
||
ALTER TABLE `insiemi` | ||
ADD PRIMARY KEY (`id`); | ||
|
||
ALTER TABLE `insiemi` | ||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; | ||
|
||
3. Popolare il DB | ||
|
||
INSERT INTO `insiemi` (`id`, `valore`, `insieme`) VALUES | ||
(1, 19, 1), | ||
(2, 2, 1), | ||
(3, 14, 1), | ||
(4, 98, 2), | ||
(5, 1, 2), | ||
(6, 19, 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
$servername = "localhost"; | ||
$username = "root"; | ||
$password = ""; | ||
$dbname = "giugno"; | ||
|
||
$conn = new mysqli($servername, $username, $password, $dbname); | ||
|
||
if ($conn->connect_error) { | ||
die("Connessione fallita: " . $conn->connect_error); | ||
} | ||
|
||
function isNumeroPresente($numero, $conn) | ||
{ | ||
$query = "SELECT COUNT(*) as count FROM insiemi WHERE valore = $numero"; | ||
$result = $conn->query($query); | ||
$row = $result->fetch_assoc(); | ||
return $row['count'] > 0; | ||
} | ||
|
||
$A = $_GET['A'] ?? null; | ||
$B = $_GET['B'] ?? null; | ||
$O = $_GET['O'] ?? null; | ||
|
||
if (!is_numeric($A) || !is_numeric($B) || $A <= 0 || $B <= 0 || !isNumeroPresente($A, $conn) || !isNumeroPresente($B, $conn) || ($O !== 'i' && $O !== 'u')) { | ||
echo "Parametri non validi o non presenti nel database o operazione non supportata."; | ||
} else { | ||
$queryA = "SELECT valore FROM insiemi WHERE insieme = $A"; | ||
$resultA = $conn->query($queryA); | ||
$insiemeA = []; | ||
while ($rowA = $resultA->fetch_assoc()) { | ||
$insiemeA[] = $rowA['valore']; | ||
} | ||
|
||
$queryB = "SELECT valore FROM insiemi WHERE insieme = $B"; | ||
$resultB = $conn->query($queryB); | ||
$insiemeB = []; | ||
while ($rowB = $resultB->fetch_assoc()) { | ||
$insiemeB[] = $rowB['valore']; | ||
} | ||
|
||
if ($O === 'u') { | ||
$nuovoInsieme = array_unique(array_merge($insiemeA, $insiemeB)); | ||
} elseif ($O === 'i') { | ||
$nuovoInsieme = array_intersect($insiemeA, $insiemeB); | ||
} | ||
|
||
if (!empty($nuovoInsieme)) { | ||
// Trova il massimo ID attualmente presente nel database e aggiungi 1 per ottenere il nuovo ID | ||
$maxIdQuery = "SELECT MAX(insieme) AS max_insieme FROM insiemi"; | ||
$resultMaxId = $conn->query($maxIdQuery); | ||
$rowMaxId = $resultMaxId->fetch_assoc(); | ||
$newId = $rowMaxId['max_insieme'] + 1; | ||
|
||
$insertQuery = "INSERT INTO insiemi (valore, insieme) VALUES "; | ||
foreach ($nuovoInsieme as $valore) { | ||
$insertQuery .= "($valore, $newId),"; | ||
} | ||
$insertQuery = rtrim($insertQuery, ','); | ||
|
||
if ($conn->query($insertQuery) === TRUE) { | ||
echo "Operazione completata con successo!"; | ||
} else { | ||
echo "Errore nell'inserimento dei dati: " . $conn->error; | ||
} | ||
} else { | ||
echo "Nessun dato da inserire."; | ||
} | ||
} | ||
|
||
$conn->close(); | ||
?> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Mio sito</title> | ||
<style> | ||
div.slider-image{ | ||
margin-top: 20px; | ||
text-align: center; | ||
} | ||
div.slider-image img{ | ||
display: inline-block; | ||
width: 100px; | ||
} | ||
div.slider-image img.current{ | ||
width: 200px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<header> | ||
<h1>Esercizio javascript/jQuery</h1> | ||
</header> | ||
<main> | ||
<h2>Tecnologie</h2> | ||
<div class="slider"> | ||
<div class="slider-image"> | ||
<img src="html.png" alt="Html" /> | ||
<img src="css.png" alt="Css" /> | ||
<img src="jquery.png" alt="jQuery" /> | ||
<img src="php.png" alt="Php" /> | ||
|
||
</div> | ||
</div> | ||
</main> | ||
</body> | ||
<script src="matteo.morellini.js" type="text/javascript"></script> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
document.addEventListener("DOMContentLoaded", function() { | ||
const images = document.querySelectorAll('.slider-image img'); | ||
const totalImages = images.length; | ||
|
||
for (let i = 2; i < totalImages; i++) { | ||
images[i].style.display = 'none'; | ||
} | ||
|
||
images[0].classList.add('current'); | ||
images[1].style.display = 'inline-block'; | ||
|
||
images.forEach(function(image, index) { | ||
image.addEventListener('click', function() { | ||
if (!this.classList.contains('current')) { | ||
const currentIndex = Array.from(images).indexOf(this); | ||
|
||
images.forEach(function(img) { | ||
img.classList.remove('current'); | ||
img.style.display = 'none'; | ||
}); | ||
|
||
this.classList.add('current'); | ||
this.style.display = 'inline-block'; | ||
|
||
if (currentIndex === 0) { | ||
images[1].style.display = 'inline-block'; | ||
} else if (currentIndex === totalImages - 1) { | ||
images[currentIndex - 1].style.display = 'inline-block'; | ||
} else { | ||
images[currentIndex - 1].style.display = 'inline-block'; | ||
images[currentIndex + 1].style.display = 'inline-block'; | ||
} | ||
} | ||
}); | ||
}); | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters