Hallo,

Ik zit vast met 2 scripts, bij de 1e (index.php) kan de gebruiker niet inloggen, bij de 2e (timetable.php) kan de gebruiker geen tijden boeken, want die worden niet weergeven dat ze al geboekt zijn.
Wie kan me uit de brand helpen?

index.php = FIXED

timetable.php
<?php require('head.php');?>

<?php
$slot = $_GET['slot'];
$day = $_GET['day'];
$username = $_SESSiON['rp_username'];
$djname = $_SESSiON['rp_djname'];
$rank = $_SESSiON['rp_rank'];
if($_GET["action"] == "book"){
$command = mysql_query("UPDATE rp_timetable SET `$slot` = '$djname' WHERE day = '$day'") or die(mysql_error());
} elseif($_GET["action"] == "unbook"){
$command = mysql_query("UPDATE rp_timetable SET `$slot` = '' WHERE day = '$day'") or die(mysql_error());
} elseif($_GET["action"] == "empty"){
$command = mysql_query("UPDATE rp_timetable SET `6`='', `1`='', `2`='', `3`='', `4`='', `5`='', `6`='', `7`='', `8`='', `9`='', `10`='', `11`='', `12`='', `13`='', `14`='', `15`='', `17`='', `18`='', `19`='', `20`='', `21`='', `22`='', `23`='', `24`='' WHERE day='$day'") or die(mysql_error());
}

if($_GET['week'] == ""){
$_GET['week'] = date("l");
}

if($_GET['day'] == ""){
$day = $_GET['week'];
$_GET['week'] = date("l");
}
$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["1"] == ""){ 
$one = "<a href='?action=book&day=$day&slot=1'>BOEK SLOT</a>"; 
}elseif($djname == $slot["1"] or $slot["1"] != "" and $rank == "Hoofd DJ"){ $one = "<a href='?action=unbook&day=$day&slot=1'><b>DJ {$slot["1"]} (Annuleren)</a></b>"; }else{$one = "<b><font color='black'>DJ {$slot["1"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["2"] == ""){ 
$two = "<a href='?action=book&day=$day&slot=2'>BOEK SLOT</a>"; 
}elseif($djname == $slot["2"] or $slot["2"] != "" and $rank == "Hoofd DJ"){ $two = "<a href='?action=unbook&day=$day&slot=2'><b>DJ {$slot["2"]} (Annuleren)</a></b>"; }else{$two = "<b><font color='black'>DJ {$slot["2"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["3"] == ""){ 
$three = "<a href='?action=book&day=$day&slot=3'>BOEK SLOT</a>"; 
}elseif($djname == $slot["3"] or $slot["3"] != "" and $rank == "Hoofd DJ"){ $three = "<a href='?action=unbook&day=$day&slot=3'><b>DJ {$slot["3"]} (Annuleren)</a></b>"; }else{$three = "<b><font color='black'>DJ {$slot["3"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["4"] == ""){ 
$four = "<a href='?action=book&day=$day&slot=4'>BOEK SLOT</a>"; 
}elseif($djname == $slot["4"] or $slot["4"] != "" and $rank == "Hoofd DJ"){ $four = "<a href='?action=unbook&day=$day&slot=4'><b>DJ {$slot["4"]} (Annuleren)</a></b>"; }else{$four = "<b><font color='black'>DJ {$slot["4"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["5"] == ""){ 
$five = "<a href='?action=book&day=$day&slot=5'>BOEK SLOT</a>"; 
}elseif($djname == $slot["5"] or $slot["5"] != "" and $rank == "Hoofd DJ"){ $five = "<a href='?action=unbook&day=$day&slot=5'><b>DJ {$slot["5"]} (Annuleren)</a></b>"; }else{$five = "<b><font color='black'>DJ {$slot["5"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["6"] == ""){ 
$six = "<a href='?action=book&day=$day&slot=6'>BOEK SLOT</a>"; 
}elseif($djname == $slot["6"] or $slot["6"] != "" and $rank == "Hoofd DJ"){ $six = "<a href='?action=unbook&day=$day&slot=6'><b>DJ {$slot["6"]} (Annuleren)</a></b>"; }else{$six = "<b><font color='black'>DJ {$slot["6"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["7"] == ""){ 
$seven = "<a href='?action=book&day=$day&slot=7'>BOEK SLOT</a>"; 
}elseif($djname == $slot["7"] or $slot["7"] != "" and $rank == "Hoofd DJ"){ $seven = "<a href='?action=unbook&day=$day&slot=7'><b>DJ {$slot["7"]} (Annuleren)</a></b>"; }else{$seven = "<b><font color='black'>DJ {$slot["7"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["8"] == ""){ 
$eight = "<a href='?action=book&day=$day&slot=8'>BOEK SLOT</a>"; 
}elseif($djname == $slot["8"] or $slot["8"] != "" and $rank == "Hoofd DJ"){ $eight = "<a href='?action=unbook&day=$day&slot=8'><b>DJ {$slot["8"]} (Annuleren)</a></b>"; }else{$eight = "<b><font color='black'>DJ {$slot["8"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["9"] == ""){ 
$nine = "<a href='?action=book&day=$day&slot=9'>BOEK SLOT</a>"; 
}elseif($djname == $slot["9"] or $slot["9"] != "" and $rank == "Hoofd DJ"){ $nine = "<a href='?action=unbook&day=$day&slot=9'><b>DJ {$slot["9"]} (Annuleren)</a></b>"; }else{$nine = "<b><font color='black'>DJ {$slot["9"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["10"] == ""){ 
$ten = "<a href='?action=book&day=$day&slot=10'>BOEK SLOT</a>"; 
}elseif($djname == $slot["10"] or $slot["10"] != "" and $rank == "Hoofd DJ"){ $ten = "<a href='?action=unbook&day=$day&slot=10'><b>DJ {$slot["10"]} (Annuleren)</a></b>"; }else{$ten = "<b><font color='black'>DJ {$slot["10"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["11"] == ""){ 
$eleven = "<a href='?action=book&day=$day&slot=11'>BOEK SLOT</a>"; 
}elseif($djname == $slot["11"] or $slot["11"] != "" and $rank == "Hoofd DJ"){ $eleven = "<a href='?action=unbook&day=$day&slot=11'><b>DJ {$slot["11"]} (Annuleren)</a></b>"; }else{$eleven = "<b><font color='black'>DJ {$slot["11"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["12"] == ""){ 
$twelve = "<a href='?action=book&day=$day&slot=12'>BOEK SLOT</a>"; 
}elseif($djname == $slot["12"] or $slot["12"] != "" and $rank == "Hoofd DJ"){ $twelve = "<a href='?action=unbook&day=$day&slot=12'><b>DJ {$slot["12"]} (Annuleren)</a></b>"; }else{$twelve = "<b><font color='black'>DJ {$slot["12"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["13"] == ""){ 
$thirteen = "<a href='?action=book&day=$day&slot=13'>BOEK SLOT</a>"; 
}elseif($djname == $slot["13"] or $slot["13"] != "" and $rank == "Hoofd DJ"){ $thirteen = "<a href='?action=unbook&day=$day&slot=13'><b>DJ {$slot["13"]} (Annuleren)</a></b>"; }else{$thirteen = "<b><font color='black'>DJ {$slot["13"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["14"] == ""){ 
$fourteen = "<a href='?action=book&day=$day&slot=14'>BOEK SLOT</a>"; 
}elseif($djname == $slot["14"] or $slot["14"] != "" and $rank == "Hoofd DJ"){ $fourteen = "<a href='?action=unbook&day=$day&slot=14'><b>DJ {$slot["14"]} (Annuleren)</a></b>"; }else{$fourteen = "<b><font color='black'>DJ {$slot["14"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["15"] == ""){ 
$fifteen = "<a href='?action=book&day=$day&slot=15'>BOEK SLOT</a>"; 
}elseif($djname == $slot["15"] or $slot["15"] != "" and $rank == "Hoofd DJ"){ $fifteen = "<a href='?action=unbook&day=$day&slot=15'><b>DJ {$slot["15"]} (Annuleren)</a></b>"; }else{$fifteen = "<b><font color='black'>DJ {$slot["15"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["16"] == ""){ 
$sixteen = "<a href='?action=book&day=$day&slot=16'>BOEK SLOT</a>"; 
}elseif($djname == $slot["16"] or $slot["16"] != "" and $rank == "Hoofd DJ"){ $sixteen = "<a href='?action=unbook&day=$day&slot=16'><b>DJ {$slot["16"]} (Annuleren)</a></b>"; }else{$sixteen = "<b><font color='black'>DJ {$slot["16"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["17"] == ""){ 
$seventeen = "<a href='?action=book&day=$day&slot=17'>BOEK SLOT</a>"; 
}elseif($djname == $slot["17"] or $slot["17"] != "" and $rank == "Hoofd DJ"){ $seventeen = "<a href='?action=unbook&day=$day&slot=17'><b>DJ {$slot["17"]} (Annuleren)</a></b>"; }else{$seventeen = "<b><font color='black'>DJ {$slot["17"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["18"] == ""){ 
$eighteen = "<a href='?action=book&day=$day&slot=18'>BOEK SLOT</a>"; 
}elseif($djname == $slot["18"] or $slot["18"] != "" and $rank == "Hoofd DJ"){ $eighteen = "<a href='?action=unbook&day=$day&slot=18'><b>DJ {$slot["18"]} (Annuleren)</a></b>"; }else{$eighteen = "<b><font color='black'>DJ {$slot["18"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["19"] == ""){ 
$nineteen = "<a href='?action=book&day=$day&slot=19'>BOEK SLOT</a>"; 
}elseif($djname == $slot["19"] or $slot["19"] != "" and $rank == "Hoofd DJ"){ $nineteen = "<a href='?action=unbook&day=$day&slot=19'><b>DJ {$slot["19"]} (Annuleren)</a></b>"; }else{$nineteen = "<b><font color='black'>DJ {$slot["19"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["20"] == ""){ 
$twenty = "<a href='?action=book&day=$day&slot=20'>BOEK SLOT</a>"; 
}elseif($djname == $slot["20"] or $slot["20"] != "" and $rank == "Hoofd DJ"){ $twenty = "<a href='?action=unbook&day=$day&slot=20'><b>DJ {$slot["20"]} (Annuleren)</a></b>"; }else{$twenty = "<b><font color='black'>DJ {$slot["20"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["21"] == ""){ 
$twentyone = "<a href='?action=book&day=$day&slot=21'>BOEK SLOT</a>"; 
}elseif($djname == $slot["22"] or $slot["21"] != "" and $rank == "Hoofd DJ"){ $twentyone = "<a href='?action=unbook&day=$day&slot=21'><b>DJ {$slot["21"]} (Annuleren)</a></b>"; }else{$twentyone = "<b><font color='black'>DJ {$slot["21"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["22"] == ""){ 
$twentytwo = "<a href='?action=book&day=$day&slot=22'>BOEK SLOT</a>"; 
}elseif($djname == $slot["22"] or $slot["22"] != "" and $rank == "Hoofd DJ"){ $twentytwo = "<a href='?action=unbook&day=$day&slot=22'><b>DJ {$slot["22"]} (Annuleren)</a></b>"; }else{$twentytwo = "<b><font color='black'>DJ {$slot["22"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["23"] == ""){ 
$twentythree = "<a href='?action=book&day=$day&slot=23'>BOEK SLOT</a>"; 
}elseif($djname == $slot["23"] or $slot["23"] != "" and $rank == "Hoofd DJ"){ $twentythree = "<a href='?action=unbook&day=$day&slot=23'><b>DJ {$slot["23"]} (Annuleren)</a></b>"; }else{$twentythree = "<b><font color='black'>DJ {$slot["23"]}</font></b>";}

$slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$day'"));
if($slot["24"] == ""){ 
$twentyfour = "<a href='?action=book&day=$day&slot=24'>BOEK SLOT</a>"; 
}elseif($djname == $slot["24"] or $slot["24"] != "" and $rank == "Hoofd DJ"){ $twentyfour = "<a href='?action=unbook&day=$day&slot=24'><b>DJ {$slot["24"]} (Annuleren)</a></b>"; }else{$twentyfour = "<b><font color='black'>DJ {$slot["24"]}</font></b>";}




echo "<div id='timetable'><center><b><u>Draaitijden</u></b><p>
<h6>-Je bekijkt nu de draaitijden van: ";
echo "$day";
echo "-</h6><p>
<a href='?week=Maandag'>Maandag</a> | <a href='?week=Dinsdag'>Dinsdag</a> | <a href='?week=Woensdag'>Woensdag</a> | <a href='?week=Donderdag'>Donderdag</a> | <a href='?week=Vrijdag'>Vrijdag</a> | <a href='?week=Zaterdag'>Zaterdag</a> | <a href='?week=Zondag'>Zondag</a><br><hr><br>
<table border='0' valign='middle' align='center'>
<tr>
<td width='640px' align='center'><u>Tijd</u></td>
<td width='640px' align='center'><u>DJ Boeking</u><td>
</tr>
<tr>
<td width='640px' align='center'>00:00 - 01:00 UUR</td>
<td width='640px' align='center'>$one<td>
</tr>
<tr>
<td width='640px' align='center'>01:00 - 02:00 UUR</td>
<td width='640px' align='center'>$two<td>
</tr>
<tr>
<td width='640px' align='center'>02:00 - 03:00 UUR</td>
<td width='640px' align='center'>$three<td>
</tr>
<tr>
<td width='640px' align='center'>03:00 - 04:00 UUR</td>
<td width='640px' align='center'>$four<td>
</tr>
<tr>
<td width='640px' align='center'>04:00 - 05:00 UUR</td>
<td width='640px' align='center'>$five<td>
</tr>
<tr>
<td width='640px' align='center'>05:00 - 06:00 UUR</td>
<td width='640px' align='center'>$six<td>
</tr>
<tr>
<td width='640px' align='center'>06:00 - 07:00 UUR</td>
<td width='640px' align='center'>$seven<td>
</tr>
<tr>
<td width='640px' align='center'>07:00 - 08:00 UUR</td>
<td width='640px' align='center'>$eight<td>
</tr>
<tr>
<td width='640px' align='center'>08:00 - 09:00 UUR</td>
<td width='640px' align='center'>$nine<td>
</tr>
<tr>
<td width='640px' align='center'>09:00 - 10:00 UUR</td>
<td width='640px' align='center'>$ten<td>
</tr>
<tr>
<td width='640px' align='center'>10:00 - 11:00 UUR</td>
<td width='640px' align='center'>$eleven<td>
</tr>
<tr>
<td width='640px' align='center'>11:00 - 12:00 UUR</td>
<td width='640px' align='center'>$twelve<td>
</tr>
<tr>
<td width='640px' align='center'>12:00 - 13:00 UUR</td>
<td width='640px' align='center'>$thirteen<td>
</tr>
<tr>
<td width='640px' align='center'>13:00 - 14:00 UUR</td>
<td width='640px' align='center'>$fourteen<td>
</tr>
<tr>
<td width='640px' align='center'>14:00 - 15:00 UUR</td>
<td width='640px' align='center'>$fifteen<td>
</tr>
<tr>
<td width='640px' align='center'>15:00 - 16:00 UUR</td>
<td width='640px' align='center'>$sixteen<td>
</tr>
<tr>
<td width='640px' align='center'>16:00 - 17:00 UUR</td>
<td width='640px' align='center'>$seventeen<td>
</tr>
<tr>
<td width='640px' align='center'>17:00 - 18:00 UUR</td>
<td width='640px' align='center'>$eighteen<td>
</tr>
<tr>
<td width='640px' align='center'>18:00 - 19:00 UUR</td>
<td width='640px' align='center'>$nineteen<td>
</tr>
<tr>
<td width='640px' align='center'>19:00 - 20:00 UUR</td>
<td width='640px' align='center'>$twenty<td>
</tr>
<tr>
<td width='640px' align='center'>20:00 - 21:00 UUR</td>
<td width='640px' align='center'>$twentyone<td>
</tr>
<tr>
<td width='640px' align='center'>21:00 - 22:00 UUR</td>
<td width='640px' align='center'>$twentytwo<td>
</tr>
<tr>
<td width='640px' align='center'>22:00 - 23:00 UUR</td>
<td width='640px' align='center'>$twentythree<td>
</tr>
<tr>
<td width='640px' align='center'>23:00 - 00:00 UUR</td>
<td width='640px' align='center'>$twentyfour<td>
</tr>
<tr>
<td width='640px' align='center'><b>$day</b></td>
<td width='640px' align='center'>";
if ($_SESSION["rp_rank"] == "Hoofd DJ"){ 
echo("<a href='?action=empty&day=$day'>LEGEN</a>");
}
echo "</td>
</tr>

</table>
</center><p></div>";
?>

<?php require('bottom.php');?>


Alvast bedankt,
Lenn
Ik denk niet dat er mensen zijn die zo veel regels door gaan spitten naar een antwoord. Belangrijker is: krijg je foutmeldingen? Wat lukt er niet precies bij het inloggen? Op deze manier krijg je misschien sneller een antwoord.

Heb je je error reporting aan staan? Wil ook nog wel eens helpen....

Succes!
Kun je niet beter for gebruiken ipv al die regels code waar in feiten steeds het zelfde staat?
Ik krijg bij index.php de foutmelding: Je inlogdata is fout... (staat ook in regel 52), terwijl ik toch de goede gegevens invul.
Bij de 2e kan ik gen slot boeken, het wordt niet opgeslagen.
Lennart schreef op 08.06.2008 09:51
Ik krijg bij index.php de foutmelding: Je inlogdata is fout... (staat ook in regel 52), terwijl ik toch de goede gegevens invul.


Klopt, je controleert daar niets, maar voert alleen iets uit. Je zult de melding dus altijd krijgen.

Ga maar eerst eens wat aan foutafhandeling e.d. doen, dit lijkt echt nergens op.
De index heb ik nu werkend door het wel te controleren ;), was ik vergeten, maar met die timetable.php kom ik echt niet uit :S.
<td width='640px' align='center'>$one<td>

Dat gaat al niet iig. zover ik weet moet je dan of gaan echo'en, of php er tussendoor doen.

dan krijg je:
<?php
echo '<td width='640px' align='center'>' . $one . '<td>';
?>

of:

<td width='640px' align='center'><?php echo $one; ?><td>

Ook adviseer ik je om zoveel mogelijk dubbele code te voorkomen, je doet bij voorbeeld bij elke slot check, opnieuw $slot setten, met precies de zelfde info. Dan kan je al zo'n 20 regels schelen.
Regel 25 t/m 143 wordt:

<?php
$query = "SELECT ....";
$result = mysql_query($query);
if($result) {
// goed uitgevoerd
if(mysql_num_rows($result) > 0) {
// er zijn rows
$slot = mysql_fetch_assoc($result);
$keys = array();
foreach($slot as $key => $value) {
if($value == "") {
$keys[$key] = "<a href='?action=book&day=".$day."&slot=".$key."'>BOEK SLOT</a>";
} elseif($djname == $value || $value != "" && $rank == "Hoofd DJ") {
$keys[$key] = "<a href='?action=unbook&day=".$day."&slot=".$key."'><b>DJ ".$value." (Annuleren)</b></a>";
} else {
$keys[$key] = "<b><span style='color: black;'>DJ ".$value."</span></b>";
}
}
} else {
echo 'Geen rijen gevonden.';
}
} else {
echo 'Query niet uitgevoerd. '.mysql_error().' in '.$query.'.';
}
?>

$keys is nu een array die per nummer een tekstje bevat. Die kun je zo uitlezen:

<?php
$time = 0;
foreach($keys as $num => $text) {
echo '<tr><td>'.((strlen($time) > 1) ? $time : '0'.$time).':00 - '.((strlen($time+1 > 1) ? ($time+1) : '0'.($time+1)).':00</td>';
echo '<td>'.$text.'</td></tr>';
$time++;
}
?>

Bespaart je alweer 100 regels hard-code.

Reageren