Witam!
Nie ma sensu wprowadzać 365 dat. Wystarczy jak zrobisz sobie pole tekstowe z formułą data type DATE I WTEDY WPROWADZASZ DATE JAKA CHCESZ I PRZYPISUJESZ ZDARZENIE.
CCREATE TABLE `wydarzenia` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`data` DATE NOT NULL,
`zdarzenie` VARCHAR(255) NULL DEFAULT NULL,
PRIMARY KEY (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=3
;
;
<?php require_once('../Connections/local.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
}
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ?
intval($theValue) : "NULL"; break;
case "double":
$theValue = ($theValue != "") ?
doubleval($theValue) : "NULL"; break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); }
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO wydarzenia (`data`, zdarzenie) VALUES (%s, %s)", GetSQLValueString($_POST['dataform'], "date"),
GetSQLValueString($_POST['wydform'], "text"));
$insertGoTo = "zdarzenie.php";
if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ?
"&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING'];
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dokument bez tytułu</title>
</head>
<body>
<form id="form1" name="form1" method="POST" action="
<?php echo $editFormAction; ?>">
<p>
<label for="dataform"></label>
<input type="text" name="dataform" id="dataform" />
</p>
<p>
<label for="wydform"></label>
<textarea name="wydform" id="wydform" cols="45" rows="5"></textarea>
<input type="submit" name="wydbutton" id="wydbutton" value="Wyślij" />
</p>
<input type="hidden" name="MM_insert" value="form1" />
</form>
</body>
</html>
a potem zrobić sobie tylko wyszukiwarkę z poziomu select data i bedziesz miał problem z głowy.
i masz już tu wyszukiwarkę po dacie
search.php
<?php require_once('../Connections/local.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
}
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ?
intval($theValue) : "NULL"; break;
case "double":
$theValue = ($theValue != "") ?
doubleval($theValue) : "NULL"; break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$query_Recordset1 = "SELECT * FROM wydarzenia";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dokument bez tytułu</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table border="1">
<tr>
<td>data</td>
</tr>
<tr>
<td>Wydarzenie
<label for="select"></label>
<select name="select" id="select">
<?php
do {
?>
<option value="
<?php echo $row_Recordset1['zdarzenie']?>">
<?php echo $row_Recordset1['data'];echo
'- '; echo $row_Recordset1['zdarzenie']?></option>
<?php
if($rows > 0) {
}
?>
</select></td>
</tr>
</table>
</form>
</body>
</html>
<?php
?>
Ten post edytował woxala123 15.01.2017, 11:00:54