Det her skulle virke
Sql:
CREATE TABLE `Kalender` (
`Id` INT NOT NULL AUTO_INCREMENT ,
`Aftale` LONGTEXT DEFAULT NULL ,
`Tid` TIME DEFAULT NULL ,
`Dag` INT DEFAULT NULL ,
`Uger` INT DEFAULT NULL ,
`Måned` INT DEFAULT NULL ,
`År` INT DEFAULT NULL ,
UNIQUE (
`Id`
)
);
Kode:
<html>
<head>
</head>
<body>
<center>
<form action="<?=$PHP_SELF;?>" method="post">
<?php
mysql_connect("localhost","brugernavn","kodeord");
mysql_select_db("database");
$query = mysql_query("SELECT * FROM Kalender");
echo "Kunde id: <select name=\\"Kunde\\">";
while($rs = mysql_fetch_array($query))
{
echo "<option value=\\"".$rs["Id"]."\\">".$rs["Id"]."</option>";
}
echo "</select>";
?>
<input type="submit" value="Tjek" />
</form>
<?php
$Farve="#0000ff";
if($Kunde)
{
$query = mysql_query("SELECT * FROM Kalender WHERE Id = ".$Kunde);
echo "<table style=\\"width:100%;\\">";
echo "<tr style=\\"background:".$Farve1.";\\">";
echo "<td>Tid</td>";
echo "<td>Dage</td>";
echo "<td>Aftale</td>";
echo "</tr>";
while($rs = mysql_fetch_array($query))
{
$Rigtig = "Nej";
$Dag = $rs["Dag"];
$Måned = $rs["Måned"];
$År = $rs["År"];
$Xtra-= $rs["Uger"]*7;
$Dato = mktime(0, 0, 0, $Måned, $Dag+$Xtra, $År);
$Datonu = mktime(0, 0, 0, date("m") , date("d") , date("Y"));
while($Rigtig=="Nej" AND $Xtra < 700)
{
$Xtra+=$rs["Uger"]*7;
$Dato = mktime(0, 0, 0, $Måned, $Dag+$Xtra, $År);
if($Dato >= $Datonu)
$Rigtig="Ja";
}
echo "<tr style=\\"background:".$Farve.";\\">";
echo "<td>".$rs["Tid"]."</td>";
echo "<td>Om ".round(((($Dato-$Datonu)/60)/60)/24)." dage!</td>";
echo "<td>".$rs["Aftale"]."</td>";
echo "</tr>";
}
echo "</table>";
}
else
{
echo "Vælg dit kunde id.";
}
?>
</center>
</body>
</html>
[Redigeret d. 18/02-04 15:13:24 af Mathias Knudsen]