Witam!
Mam następującą strone:
<?php
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Dziennik obecności - Sprawdzanie obecności</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/addit.css" rel="stylesheet">
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<?php
include 'skrypty/cn.php'; //otwieranie bazy
?>
<?php
{
?>
<!-- ================================================================================
====== -->
<!-- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||| -->
<!-- ================================================================================
====== -->
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a href="index.php">
<button type="button" class="btn btn-primary">
<span class="glyphicon glyphicon-home"></span>
</button>
</a>
 | 
<a href="obecnosc.php"><button type="button" class="btn btn-info navbar-btn">SPRAWDZANIE OBECNOŚCI</button></a>
<a href="lista.php"><button type="button" class="btn btn-default navbar-btn">Lista uczniów</button></a>
<a href="dodawanie.php"><button type="button" class="btn btn-default navbar-btn">Dodawanie ucznia</button></a>
</div>
</div>
</div>
<div class="container">
<br><h1 class="text-center">Sprawdzanie obecności</h1>
<h2 class="text-center">
<?php echo date("d-m-Y"); ?></h2> <br>
<form action="obecnosc.php" method="POST">
<table class="table table-hover lista">
<thead>
<tr>
<th>#</th>
<th>Imię</th>
<th>Nazwisko</th>
<th></th>
</tr>
</thead>
<?php
if($_GET['action'] == 'set') {
if(isset($_GET['obecny']) && isset($_GET['imie'])) {
mysql_query(" INSERT INTO `uczniowie_`(`uid`, `imie`, `data`) VALUES ('$uid', '$uname', '$data') ");
if ($wstaw) {
echo '<button type="button" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-remove"></span>   Wystąpił błąd podczas dodawania obecności!</button>'; }
else {
echo '<button type="button" class="btn btn-success btn-xs"><span class="glyphicon glyphicon-ok"></span>   Uczeń jest obecny!</button>'; }
}
}
echo '<td>' . $row['id'] . '</td>'; echo '<td>' . $row['imie'] . '</td>'; echo '<td>' . $row['nazwisko'] . '</td>'; <form action="?action=set&obecny='.$row['id'].'&imie='.$row['imie'].'" method="post">
<input type="submit" class="btn btn-default" name="submit_check" value="Obecny!" />
</form>
</td>';
}
?>
</table>
</form>
<hr>
<footer>
<p class="text-left">© Company 2014 | Created by Vertisan</p>
<p class="text-right">
<?php
include 'skrypty/con_test.php';
?>
</p>
</footer>
</div> <!-- /container -->
<!-- ================================================================================
====== -->
<!-- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||| -->
<!-- ================================================================================
====== -->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
<script>
$('.dymek').tooltip();
</script>
<?php
}
include 'skrypty/dc.php'; //zamykanie połączenia z bazą
?>
</body>
</html>
Mój problem polega na tym że rekordy dodają się po kilka razy ('imie' z taką samą 'datą')
Chodzi mi o to, żeby była możliwość dodania takiego rekordu tylko raz, wiem żeby zrobić pętle, tylko nie wiem jak ją zdefiniować (warunek, zapytanie itd.)
+----+-----+--------+----------+
| ID | uid | imie | DATA |
+----+-----+--------+----------+
| 1 | 2 | Maciek | 27052014 |
| 2 | 2 | Maciek | 27052014 |
| 3 | 3 | Maciek | 27052014 |
| 4 | 5 | Romek | 27052014 |
| 5 | 5 | Romek | 27052014 |
| 6 | 6 | Paweł | 27052014 |
| 7 | 6 | Paweł | 27052014 |
| 8 | 4 | Piotr | 28052014 |
| 9 | 2 | Maciek | 28052014 |
| 10 | 2 | Maciek | 28052014 |
| 11 | 2 | Maciek | 28052014 |
+----+-----+--------+----------+
Pozdrawiam