Browse Source

bugfix for day.php

master
n0m1s 10 years ago
parent
commit
6169e5e651
2 changed files with 19 additions and 30 deletions
  1. +1
    -1
      databaseOperations.php
  2. +18
    -29
      day.php

+ 1
- 1
databaseOperations.php View File

@ -172,7 +172,7 @@ function getEventsByDate($db, $date)
try
{
$request = $db->prepare('SELECT * FROM event WHERE (event_dtstart <= :date AND event_dtend >= :date)');
$request->execute(array('date'=>date("Y-m-d",$date)));
$request->execute(array('date'=>date("Y-m-d",strtotime($date))));
$result = $request->fetchAll();
$request->closeCursor();
return $result;


+ 18
- 29
day.php View File

@ -1,3 +1,9 @@
<?php
include_once('databaseOperations.php');
$db = connect();
$date = htmlspecialchars($_GET['date']);
?>
<!DOCTYPE html>
<html>
<head>
@ -15,35 +21,18 @@
</header>
<div id="descEvent">
<h1><?php
date_default_timezone_set('America/Los_Angeles');
$date = $_GET["date"];
echo date('d M Y',strtotime($date));
?></h1>
<?php
class MyDB extends SQLite3
{
function __construct()
{
$this->open('testdb.db');
}
}
$db = new MyDB();
if(!$db) echo $db->lastErrorMsg();
$date = $_GET["date"];
$ret = $db->query('SELECT titre, dtstart, dtend, localisation, description FROM events WHERE dtstart<"'.date('Y-m-d',strtotime($date . "+1 days")).'" AND dtstart>"'.date('Y-m-d',strtotime($date)).'";');
//Show events
while($row = $ret->fetchArray(SQLITE3_ASSOC) ) {
echo "<div id=\"event\">\n";
echo "<h2>".$row['titre']."</h2>\n";
echo "<div id=\"dateLieu\">".date('H:i',strtotime($row['dtstart']))." - ".date('H:i',strtotime($row['dtend'])).". ".$row['localisation']."</div>\n";
echo "<div id=\"descfull\">".$row['description'] ."</div>\n<div id=\"More\"><a href=\"\">En savoir +</a></div>\n</div>\n";
}
$db->close();
?>
<h1><?php echo date('d M Y',strtotime($date)); ?></h1>
<?php
$ret = getEventsByDate($db, $date);
//Show events
foreach ($ret as $row)
{
echo "<div id=\"event\">\n";
echo "<h2>".$row['event_title']."</h2>\n";
echo "<div id=\"dateLieu\">".date('H:i',strtotime($row['event_dtstart']))." - ".date('H:i',strtotime($row['event_dtend'])).". ".$row['event_localisation']."</div>\n";
echo "<div id=\"descfull\">".$row['event_description'] ."</div>\n<div id=\"More\"><a href=\"\">En savoir +</a></div>\n</div>\n";
}
?>
</div>
</body>
</html>

Loading…
Cancel
Save