1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| ?php
/* Connexion bdd */
try
{
$bdd = new PDO('mysql:host=localhost;dbname=historique;charset=utf8', 'root', '');
}
catch (Exception $e)
{
die('Erreur : ' . $e->getMessage());
}
$rep = $bdd->query("TRUNCATE TABLE historique");
// envoie des données du fichier txt à la base
$req =$bdd->query("LOAD DATA INFILE 'C:/wamp/www/MFR/text5.txt'
INTO TABLE historique
FIELDS
TERMINATED BY ';'
ENCLOSED BY '\\\"'
ESCAPED BY '\\\\'
LINES
STARTING BY ''
TERMINATED BY '\\n'
(heure,site,ip)
") or die (print_r($bdd->errorInfo()));
if (!isset($_GET['startrow'])) {
$startrow=0;
}
else {
$startrow = $_GET['startrow'];
}
$fetch = $bdd->query("SELECT * FROM historique LIMIT $startrow,10")or
die(mysql_error());
echo "<table border=2>";
echo "<tr><td>IP</td><td>SITE</td><td>DATE</td></tr>";
while ($row=$fetch->fetch()){
echo "</td> <td> ";
echo $row['heure'];
echo "</td> <td>" ;
echo $row['site'];
echo "</td> <td>" ;
echo $row['ip'];
echo "</td> </tr>" ;
}
echo"</table>";
echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow+10).'">Next</a>';
$prev = $startrow - 10;
//only print a "Previous" link if a "Next" was clicked
if ($prev >= 0)
echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.$prev.'">Previous</a>';
?>
</table> |
Partager