Browse Source

Instalācijā ieviešam arī nopirkto brikešu skait

master
Vitalijss 5 years ago
parent
commit
8a59635e54
2 changed files with 15 additions and 3 deletions
  1. +5
    -1
      include/install.php
  2. +10
    -2
      index.php

+ 5
- 1
include/install.php View File

@@ -25,6 +25,8 @@ echo '<label>Datubāzes parole</label>';
echo '<input class="w3-input" type="text" name="password">'; echo '<input class="w3-input" type="text" name="password">';
echo '<label>Datubāzes nosaukums</label>'; echo '<label>Datubāzes nosaukums</label>';
echo '<input class="w3-input" type="text" name="dbname"><br>'; echo '<input class="w3-input" type="text" name="dbname"><br>';
echo '<label>Cik brikešu iepakojumu nopirkts:</label>';
echo '<input class="w3-input" type="text" name="nopirkts"><br>';
echo '<input type="submit" class="w3-button w3-green" name="db_saglabat" value="Saglabāt"> echo '<input type="submit" class="w3-button w3-green" name="db_saglabat" value="Saglabāt">
</form> </form>
</div> </div>
@@ -37,6 +39,7 @@ echo '<input type="submit" class="w3-button w3-green" name="db_saglabat" value="
$username1 = $_POST['user']; $username1 = $_POST['user'];
$password1 = $_POST['password']; $password1 = $_POST['password'];
$dbname1 = $_POST['dbname']; $dbname1 = $_POST['dbname'];
$brnopirkts = $_POST['nopirkts'];
// Create connection // Create connection
$conn1 = mysqli_connect($servername1, $username1, $password1, $dbname1); $conn1 = mysqli_connect($servername1, $username1, $password1, $dbname1);
mysqli_set_charset( $conn, 'utf8'); mysqli_set_charset( $conn, 'utf8');
@@ -67,9 +70,10 @@ echo '<input type="submit" class="w3-button w3-green" name="db_saglabat" value="
PatDatums text(15) NOT NULL, PatDatums text(15) NOT NULL,
PRIMARY KEY (PatID));"; PRIMARY KEY (PatID));";


$nopirkts_db = "INSERT INTO Briketes (BrikNopirkts,BrikAtlicis) VALUES ($brnopirkts,$brnopirkts);";
//Darīšana //Darīšana
mysqli_query($conn1,$tabulabriketes); mysqli_query($conn1,$tabulabriketes);
mysqli_query($conn1,$nopirkts_db);
if(mysqli_query($conn1,$tabulapaterins)) if(mysqli_query($conn1,$tabulapaterins))
{ {
//Izveidojam db.php failu //Izveidojam db.php failu


+ 10
- 2
index.php View File

@@ -5,10 +5,16 @@
<link rel="stylesheet" href="/include/css/w3.css"> <link rel="stylesheet" href="/include/css/w3.css">
<?php <?php
include('include/db.php'); include('include/db.php');
//Attēlojam, cik brikešu ir atlicis.
$meklejam = "SELECT * FROM Briketes WHERE BrikID = 1;";
$result = mysqli_query($conn,$meklejam);
?> ?>
<div class="w3-container w3-center"> <div class="w3-container w3-center">
<form action="" method="POST"> <form action="" method="POST">
<h2>Reģistrēt iztērētās briketes</h2> <h2>Reģistrēt iztērētās briketes</h2>
<?php while($row = mysqli_fetch_assoc($result)) {
echo '<h3>Atlikuši '.$row['BrikAtlicis'].' iepakojumi</h3>';
} ?>
<img src="/img/briketes.png" alt="Briketes"> <img src="/img/briketes.png" alt="Briketes">
<br> <br>
<input type="submit" name="pievienot" class="w3-button w3-jumbo w3-green" value="-1"> <input type="submit" name="pievienot" class="w3-button w3-jumbo w3-green" value="-1">
@@ -26,9 +32,9 @@ if(isset($_POST['pievienot']))
$atnemt = "UPDATE Briketes SET BrikAtlicis = BrikAtlicis-1 WHERE `BrikID` = 1"; $atnemt = "UPDATE Briketes SET BrikAtlicis = BrikAtlicis-1 WHERE `BrikID` = 1";
mysqli_query($conn,$atnemt); mysqli_query($conn,$atnemt);
if (mysqli_query($conn,$pievienot)) { if (mysqli_query($conn,$pievienot)) {
echo "New record created successfully";
//echo "New record created successfully";
} else { } else {
echo "Error: " . $pievienot . "<br>" . mysqli_error($conn);
//echo "Error: " . $pievienot . "<br>" . mysqli_error($conn);
} }
echo ' <style> echo ' <style>
@@ -37,6 +43,8 @@ if(isset($_POST['pievienot']))
opacity: 5.9; opacity: 5.9;
} }
</style>'; </style>';
header( "refresh:2;url=index.php" );
} }

?> ?>



Loading…
Cancel
Save

Powered by TurnKey Linux.