ecco qua..piu o meno dovrebbe essere questo il codice in PHP necessario! spero che ti aiuti, se hai ancora bisogno dimmelo!
Codice PHP:
<?php
class DB {
public function recordArray($sql) {
$array = array();
$mysqli = new mysqli('localhost', 'user', 'password', 'cassaGestionaleNegozioNicola');
if ($mysqli) {
if ($result = $mysqli->query($query)) {
while ($row = $result->fetch_assoc())
$array[] = $row;
$result->close();
} else
die ("Errore nella query: " . $mysqli->error;)
} else
die("Errore nella connessione: " . $mysqli->connect_error);
$mysqli->close();
return $array;
}
}
$db = new DB();
// valori passati dopo la ricarica di questa pagina e la chiusura di modificaOrdini.php
$modificati = $_COOKIE['modified'];
$recID = $_COOKIE['recID'];
// metto in un array i codici a barre degli articoli già modificati
for ($i=1; $i<$modificati; $i++;)
$arrCodici[] = $_POST['codice-' . $i];
?>
<!DOCTYPE html>
<html>
<head>
<title>DataTables</title>
<meta charset="UTF-8">
<script>
function showWindow(sNomeWin, sPage, iWidth, iHeight) {
var handle = window.open(sPage, sNomeWin, 'width=' + iWidth + ', height=' + iHeight + ', 0, 0, 0, 0, 0, 0, 0 ');
}
</script>
</head>
<body>
<div id="home">
<div data-role="header"><h1>EasyManagement</h1></div>
<div>
<table id="datatables" class="display">
<thead>
<tr>
<th>Codice Barre</th>
<th>Nome Articolo</th>
<th>Quantità</th>
<th>Soglia Minima</th>
<th></th>
</tr>
</thead>
<tbody>
<form id="articoli" method="post">
<?php
$query = "SELECT a.nomearticolo,a.soglia,q.quantita,d.codicebarre FROM articolidett a, articoliquantita q, articoli d where a.codarticolo = d.codarticolo and a.codarticolo = q.codarticolo;"
$rows = $db->recordArray($query);
if (count($rows)) {
while ($row = mysql_fetch_array($result)) {
$tab = '<tr><td>' . $row['codicebarre'] . '</td><td>' . $row['nomearticolo'] . '</td>';
$tab .= '<td>' . $row['quantita'] . '</td><td>' . $row['soglia'] . '</td>';
$tab .= '<td><input type="button" value="..." onclick="showWindow(\'MODIFICA ORDINI\', \'modificaOrdini?codice=' . $row['codicebarre'] . '\', 500, 500)"></td>';
$tab .= '</tr>';
} ?>
</form>
</tbody>
</table>
<?php if ($modificato) { ?>
<?php // ci sono dei record modificati da visualizzare ?>
<table id="tableOrdini" class="display">
<thead>
<tr>
<th>Codice Barre</th>
<th>Nome Articolo</th>
<th>Quantità</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
for ($i=1; $i<=$modificati; $i++) {
$tab = '<tr><td>' . $row['codicebarre'] . '</td><td>' . $row['nomearticolo'] . '<input type="hidden" name="codice-"' . $i . '"></td>';
$tab .= '<td>' . $row['quantita'] . '</td><td>' . $row['soglia'] . '</td>';
$tab .= '<td><input type="button" value="..." onclick="showWindow(\'MODIFICA ORDINI\', \'modificaOrdini?codice=' . $row['codicebarre'] . '\', 500, 500)"></td>';
$tab .= '</tr>';
}
// aggiungo in fondo il record appena modificato
$row = $db->recordArray("SELECT * FROM articoliDett WHERE codiceBarre = " . $recID);
$tab = '<tr><td>' . $row['codicebarre'] . '</td><td>' . $row['nomearticolo'] . '</td>';
$tab .= '<td>' . $row['quantita'] . '</td><td>' . $row['soglia'] . '</td>';
$tab .= '</tr>';
?>
</tbody>
</table>
<?php } ?>
</div>
</div>
</body>
</html>