PDA

View Full Version : Officially driving me insane now; best way to do a DJ Timetable



lolwut
26-10-2007, 10:25 PM
Right well yeah, I've already got a DJ panel done, well basically all done, it's missing a Timetable.
I've been trying for a good few hours now and it's mind numbingly boring.

Have any of you got any good ideas for how I could make a Timetable?
My idea for it sucks and doesn't work.
Any suggestions would be appreciated.

rh4u
26-10-2007, 10:27 PM
use a table and echo the information from the db?

lolwut
26-10-2007, 10:31 PM
Very smart.
What I was hoping for is ideas for the best methods to do that, I know how to code the PHP, but I'm wondering how best to lay out the SQL for ease of use and how to lay out the actual timetable pages.

rh4u
26-10-2007, 10:37 PM
Very smart.

That was sarcasm right?

lolwut
26-10-2007, 10:43 PM
Unfortunatley, yes.
Still needing ideas for this.

Snex
26-10-2007, 10:47 PM
I like the way that airhabbo have done it etc. with the one table as it means thet you don't have to reload the page which makes it easier for the viewer.

Invent
26-10-2007, 11:10 PM
Two popular ways.

AJAX:
http://79.64.232.202/powerpanel/frontend/timetable/

NON-AJAX:
http://79.64.232.202/powerpanel/frontend/timetable/habbo.php

L!nK
26-10-2007, 11:17 PM
Two popular ways.

AJAX:
http://79.64.232.202/powerpanel/frontend/timetable/

NON-AJAX:
http://79.64.232.202/powerpanel/frontend/timetable/habbo.php

Ohh Ajax version is nice

Beau
29-10-2007, 07:59 AM
I can tell you now, unless you're using array loops, which I've NEVER got the hang of, it's a lot of hardcoding.

I've recently recoded the backend for HabboHut, which includes a schedule system. I have a table on the database called 'schedule'. Inside, there are 25 columns. One for day, and one for every hour of the day (I've called them 'hour_12' (for 12pm as an example), as MySQL won't work properly with columns beginning with numbers. Inside the table, I have seven rows, one for every day of the week. The day column is filled with the day (eg. Monday, Tuesday, Wednesday).

When I'm booking a new slot, I'll grab the day and hour the user is booking, and slot it in like so:



$query = "UPDATE schedule SET $hour='$djname' WHERE day='$day'";
$query = mysql_query($query);
Returning the data in a timetable is the really annoying part. I've got it set up as a table, where each cell is returning a piece from the database. Eg.



$query = "SELECT * FROM schedule WHERE day='Tuesday'";
$query = mysql_query($query);
$tuesday = mysql_fetch_assoc($query);

echo $tuesday['hour_9']; // Will echo the slot booked for 9am on Tuesday
Unfortunately, this means entering a code echoing the data in each cell of the timetable = 168 rows, which is a lot of hardcoding. I pondered this issue for ages, and it seemed to be the only way to do it. Took me an hour and a half, but it's done now!

Invent
29-10-2007, 04:36 PM
I can tell you now, unless you're using array loops, which I've NEVER got the hang of, it's a lot of hardcoding.

Timetables are quite easy to code :S

I made mine in like 10 Minutes. Including the AJAX controls. (Changing days, etc).

Beau
30-10-2007, 04:18 AM
Timetables are quite easy to code :S

I made mine in like 10 Minutes. Including the AJAX controls. (Changing days, etc).

Ah yes, but you'd have seperate pages for each day? I didn't do that, I have it all in a table, so it was all hard coded.

Invent
30-10-2007, 09:42 PM
Ah yes, but you'd have seperate pages for each day? I didn't do that, I have it all in a table, so it was all hard coded.

No...it was all done using one page...?

DeejayMachoo$
30-10-2007, 11:10 PM
Made one for out panel so this isnt needed any more.

Beau
31-10-2007, 04:52 AM
No...it was all done using one page...?

I repeat, in table form? I'm not talking about booking/unbooking slots, I'm talking about echoing the details of the slot to the end user. If you managed to do this in table form in like ten minutes, I'd be interested in knowing how :P

redtom
31-10-2007, 10:39 AM
I repeat, in table form? I'm not talking about booking/unbooking slots, I'm talking about echoing the details of the slot to the end user. If you managed to do this in table form in like ten minutes, I'd be interested in knowing how :P

***? how is echoing somthing in a table hard?

DeejayMachoo$
31-10-2007, 10:43 AM
***? how is echoing somthing in a table hard?



<?
$table = mysql_query("SELECT * from timetable WHERE id='1'");
$table = mysql_fetch_array($table);
if ($table[monday00] == '') {
echo("&nbsp;");
} else {
echo("$table[monday00]");
} ?>
?>

Invent
31-10-2007, 05:31 PM
<?php

include("../../includes/config.php");
include("../../includes/functions.php");

function clean($var)
{

$var = htmlspecialchars( $var, ENT_QUOTES );

if( get_magic_quotes_gpc( ) ) {

$var = stripslashes( $var );

}

$var = str_replace( "\"", "", $var );
$var = htmlentities( $var );
$var = mysql_real_escape_string( $var );

return $var;

}

if($_GET['day'] && !$_GET['action'] && !$_GET['slot']) {
?>
<style type="text/css">
<!--
td, a, a:link, a:active, input, select, textarea
{
font-size: 12px;
font-family: Trebuchet MS;
color: #6d6d6d;
text-decoration: none;
}
-->
</style>
<br><div style="color: #999999; text-align: center">You are currently viewing <strong><div style="text-transform: uppercase"><? echo("". clean($_GET['day'] .""); ?></div></strong></div><br />
<table width="200" align="center" cellpadding="0" cellspacing="0" style="border: solid 1px #EEEEEE">
<tr>
<td width="73" align="center"><div align="center"><strong>Time</strong></div></td>
<td width="111" align="center"><div align="center"><strong>Options</strong></div></td>
</tr>
<tr>
<td align="center">00:00</td>
<td align="center">
<?php

$time = "00:00";


$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}


?></td>
</tr>
<tr>
<td align="center">01:00</td>
<td align="center"> <?php

$time = "01:00";


$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}


?></td>
</tr>

<tr>
<td align="center">02:00</td>
<td align="center"> <?php

$time = "02:00";


$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}


?></td>
</tr>
<tr>
<td align="center">03:00</td>
<td align="center"> <?php


$time = "03:00";
$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}


?></td>
</tr>
<tr>
<td align="center">04:00</td>
<td align="center"> <?php

$time = "04:00";
$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}


?></td>
</tr>
<tr>
<td align="center">05:00</td>
<td align="center"> <?php

$time = "05:00";

$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}


?></td>
</tr>
<tr>
<td align="center">06:00</td>
<td align="center"> <?php

$time = "06:00";


$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}


?></td>
</tr>
<tr>
<td align="center">07:00</td>
<td align="center"><?php

$time = "07:00";


$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}


?></td>
</tr>
<tr>
<td align="center">08:00</td>
<td align="center"> <?php

$time = "08:00";

$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}


?></td>
</tr>
<tr>
<td align="center">09:00</td>
<td align="center"> <?php

$time = "09:00";

$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}


?></td>
</tr>
<tr>
<td align="center">10:00</td>
<td align="center"><?php

$time = "10:00";

$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}


?></td>
</tr>
<tr>
<td align="center">11:00</td>
<td align="center"><?php

$time = "11:00";

$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}


?></td>
</tr>
<tr>
<td align="center">12:00</td>
<td align="center"><?php

$time = "12:00";

$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}

?></td>
</tr>

<tr>
<td align="center">13:00</td>
<td align="center"><?php

$time = "13:00";

$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}


?></td>
</tr>
<tr>
<td align="center">14:00</td>
<td align="center"><?php

$time = "14:00";

$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}


?></td>
</tr>
<tr>
<td align="center">15:00</td>
<td align="center"><?php

$time = "15:00";
$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}


?></td>
</tr>

<tr>
<td align="center">16:00</td>
<td align="center"><?php

$time = "16:00";

$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");

}


?></td>
</tr>
<tr>
<td align="center">17:00</td>
<td align="center"><?php

$time = "17:00";

$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}


?></td>
</tr>
<tr>
<td align="center">18:00</td>
<td align="center"><?php

$time = "18:00";
$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}


?></td>
</tr>
<tr>
<td align="center">19:00</td>
<td align="center"><?php

$time = "19:00";

$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}

?></td>
</tr>
<tr>
<td align="center">20:00</td>
<td align="center"><?php

$time = "20:00";

$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}


?></td>
</tr>
<tr>
<td align="center">21:00</td>
<td align="center"><?php

$time = "21:00";
$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}


?></td>
</tr>
<tr>
<td align="center">22:00</td>
<td align="center"><?php

$time = "22:00";

$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}


?></td>
</tr>
<tr>
<td align="center">23:00</td>
<td align="center"><?php

$time = "23:00";

$grabs = mysql_fetch_array(mysql_query("SELECT * FROM time". clean($_GET['day']) ." WHERE time = '$time'"));

if($grabs["slot"] == "") {
echo("No DJ");
}
else {
echo("<strong><span id=\"forum2\"><a href=\"../djprofile.php?name=". $grabs["slot"] ."\" target=\"_self\">DJ ". $grabs["slot"] ."</a></span></strong>");
}


?></td>
</tr>
</table>
<?
die;
}


?>
<html>
<head>
<title>DJ Profile</title>
<script type="text/javascript" src="../../includes/prototype.js"></script>
<script type="text/javascript" src="../../includes/scriptaculous.js"></script>
<script type="text/javascript" language="javascript">
var xmlHttp

function GetXmlHttpObject(){
var objXMLHttp=null
if (window.XMLHttpRequest){
objXMLHttp=new XMLHttpRequest()
}else if (window.ActiveXObject){
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}

function GetSlots(day){
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null){
alert ("Browser does not support HTTP Request")
return
}

var url="index.php?day="+day
xmlHttp.open("GET",url,true)
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) {
document.getElementById("timetable").innerHTML = xmlHttp.responseText;
}
};
xmlHttp.send(null);
}

////////////>
</script>
<link href="../../css/inside.css" rel="stylesheet" type="text/css" />
</head>
<body style="margin: 10px;">
<div id="content_title">
Timetable
</div>
<div id="content" style="text-align: center">
<br />
<a onClick="GetSlots('monday')" style="cursor: pointer">Monday</a> | <a onClick="GetSlots('tuesday')" style="cursor: pointer">Tuesday</a> | <a onClick="GetSlots('wednesday')" style="cursor: pointer">Wednesday</a> | <a onClick="GetSlots('thursday')" style="cursor: pointer">Thursday</a> | <a onClick="GetSlots('friday')" style="cursor: pointer">Friday</a> | <a onClick="GetSlots('saturday')" style="cursor: pointer">Saturday</a> | <a onClick="GetSlots('sunday')" style="cursor: pointer">Sunday</a>
<div id="timetable" style="text-align: center"></div>
</div>
</body>
</html>
I coded that a while back, it can be done MUCH more efficiently using arrays.

lolwut
31-10-2007, 05:36 PM
Yoink.

Invent
31-10-2007, 05:38 PM
Yoink.

Use it if you want. Just say I made it ;)

lolwut
31-10-2007, 05:42 PM
I didn't mean it, I've just quoting Yoink all day.
Matt coded one already. Which suits us better(/is better). Thanks anyway.

Invent
31-10-2007, 05:43 PM
Matt coded one already. Which, is probably better. Thanks anyway.

lawl..

lolwut
31-10-2007, 05:44 PM
SPAMz. ^
Well, it suits us better.

Beau
01-11-2007, 06:10 AM
***? how is echoing somthing in a table hard?

You misunderstand me by hard-coding, I mean coding that isn't dynamically set. Not coding that is difficult :P Echoing is easy, it's just annoying having to do it 168 times!

DeejayMachoo$
01-11-2007, 08:59 AM
You misunderstand me by hard-coding, I mean coding that isn't dynamically set. Not coding that is difficult :P Echoing is easy, it's just annoying having to do it 168 times!i understand you :)

Want to hide these adverts? Register an account for free!