29. januar 2005 - 11:07
Der er
5 kommentarer og
1 løsning
Simpel streng som driller
Hvordan putter jeg nedenstående <A HREF=..>:
<a href="#" onClick="MyWindow=window.open('popup.php?id=<? echo $foo[id]; ?>','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=200,left=50,top=50'); return false;">titel</a>
Ind i denne linje: (der hvor der står <A HREF=".$foo['id'...>
<?php
$res[$today]['title'][] = "<b><A HREF=".$foo['id'].">".$foo['title']."</A></b> (Dag ".$i."/".$foo['days'].")<BR>";
?>
Lige nu er der jo for mange " og ' -er...
29. januar 2005 - 11:30
#1
$res[$today]['title'][] = "<a href=\"#\" onClick=\"MyWindow=window.open('popup.php?id=".$foo['id']."','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=200,left=50,top=50'); return false;\">".$foo['title']."</a>";
02. februar 2005 - 20:56
#2
Tak skal du have... Måske du lige gider hjælpe med en enkelt ting mere:
Min kalender hopper underligt rundt i månederne. Når man først kommer ind viser den ikke februar (denne måned), hvis man går en tilbage viser den måned, men hvis man kommer tilbage til januar er der både januar ved month=0 og month=1 ... desuden er der en month=13
Kan man gøre noget ved den måned frem og måned tilbage, så de ikke viser 0 og 13 ? Og så den viser dagens måned når man først loader scriptet. (echo $MONTHNAME[$month];)
02. februar 2005 - 20:56
#3
<?php
# Functions
function date_info($info, $month, $year) {
return date($info, mktime(0,0,0,$month,1,$year));
}
# DB CONNECT
open();
function getBookings($month, $year) {
$sql = mysql_query("
SELECT TO_DAYS(startdate)-TO_DAYS('$year-$month-01')+1 AS day, id, days, rooms, title, beskrivelse, type
FROM testkalender
WHERE startdate<='$year-$month-31' && TO_DAYS(startdate)+days>=TO_DAYS('$year-$month-01')
") or die(mysql_error());
$res = array();
if (!mysql_num_rows($sql)) return $res;
while ($foo = mysql_fetch_assoc($sql)) {
if ($foo['days'] == 1) {
$res[$today]['title'][] = "<b><a href=\"#\" onClick=\"MyWindow=window.open('popup.php?id=".$foo['id']."','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=200,left=50,top=50'); return false;\">".$foo['title']."</a></b>";
$res[$foo['day']]['picture'][]="<IMG SRC=graph/kalender_".$foo['type'].".jpg alt=".$foo['type']." name=".$foo['type'].">\n";
$res[$foo['day']]['beskrivelse'][]=$foo['beskrivelse']."\n\n";
$res[$foo['day']]['totalrooms'] = $res[$foo['day']]['totalrooms'] + $foo['rooms'];
} else {
$today = $foo['day'];
for($i=1; $i<=$foo['days']; $i++) {
for($i=1; $i<=$foo['days']; $i++) {
if ($today>0){
$res[$today]['title'][] = "<b><a href=\"#\" onClick=\"MyWindow=window.open('popup.php?id=".$foo['id']."','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=200,left=50,top=50'); return false;\">".$foo['title']."</a></b>";
$res[$today]['picture'][]="<IMG SRC=graph/kalender_".$foo['type'].".jpg alt=".$foo['type']." name=".$foo['type'].">";
$res[$today]['beskrivelse'][]=$foo['beskrivelse']."\n\n";
$res[$today]['totalrooms'] = $res[$today]['totalrooms'] + $foo['rooms'];
}
$today++;
}
}
}
}
return $res;
}
# Pre-values
$year = date('Y');
$month = date('m');
# Catch month or year if passed
if (isset($_GET["month"]) && $_GET["month"] >= 1 && $_GET["month"] <= 12) $month = $_GET["month"];
if (isset($_GET["year"]) && $_GET["year"] > $year) $year = $_GET["year"];
# Static date names - language specific
$MONTHNAME = array("", "Januar", "Februar", "Marts", "April", "Maj", "Juni", "Juli", "August", "September", "Oktober", "November", "December");
# Month for listing
$listingmonth = date('n');
if ($year != date('Y')) $listingmonth = 1;
# Init months array with days and first day of month
$MONTHINFO = array();
# Initialize days in month
$MONTHINFO["days"] = date_info("t", $month, $year);
$MONTHINFO["firstday"] = date_info("w", $month, $year);
$MONTHINFO["weekno"] = date_info("W", $month, $year);
# Get room assignment
$ASSIGNMENT = getBookings($month, $year);
# Set colorclass for td
$class = "red";
if ((($MONTHS["firstday"]+$i)%7) == 6) $class = "normal";
?>
</CENTER><BR><BR>
<div align="center"><B><<-- <a href='index.php?side=kalender&year=<?php echo $year; ?>&month=<?php echo $month-1; ?>'>Tilbage</a> |
<?php
echo $MONTHNAME[$month];
?> <?php echo $year; ?> |
<a href='index.php?side=kalender&year=<?php echo $year; ?>&month=<?php echo $month+1; ?>'>Frem --></a> </B><BR>
<table border="1" width="430" border="0" cellspacing="0" cellpadding="0" align="center">
<tr valign="top">
<td width="80" colspan="2" class="month" valign="top">Dato</td>
<td colspan="2" class="month" valign="top">Arrangement</td>
</tr>
<?php for ($i=1; $i<=$MONTHINFO["days"]; $i++) { ?>
<tr>
<td colspan='2' width="350" valign="top" class="<?php echo $class; ?>"><?php echo $i .".". $month ."-". $year; ?>
</td><td colspan='2' width="350" valign="top" class="<?php echo $class; ?>">
<?php # Insert week no if week is starting
if ((($MONTHINFO["firstday"]+$i)%7) == 2);
// BILLEDE SKAL IND HER !!!
if (isset($ASSIGNMENT[$i])){
echo "<br><table>";
for ($eventnumber=0; $eventnumber<count($ASSIGNMENT[$i]['picture']); $eventnumber++){
echo "<tr><td width='50' ALIGN='CENTER' VALIGN='TOP'>";
echo $ASSIGNMENT[$i]['picture'][$eventnumber];
echo "</td><td width='350' VALIGN='TOP'><DIV CLASS='normal'>";
echo nl2br($ASSIGNMENT[$i]['title'][$eventnumber]);
echo "</DIV></td></tr>";
}
echo "</table>";
echo $ASSIGNMENT[$i]['totalrooms'] . " i alt.";
}
?>
</td>
</tr>
<?php } ?>
</table>