Jump to content

Please help, I need your suggestions!


elmas156

Recommended Posts

Hey everyone,

 

I'm pretty new to php but I've gotten enough help on this forum to value all of your opinions so I'm going to ask for just that.  I'm developing a website that I'm going to have to have some type of scheduling system that includes a calendar.  In my opinion, I am not even close to having the knowledge to be able to create such a system by developing my own code.  I know that there are some ready-made calendars that can be purchased for use and that's what I'm considering doing.  The problem is, I'm on a very tight budget (about $5.00 is my max ;-), which I why I'm taking the time and building it myself.  I have found a php calendar that I can use for free that has a link to the developers website as an advertisement.  So, my question is do you guys think this would be an ok idea, would it be better to purchase one or is it not as difficult as I'm thinking and should I take some extra time and learn to do it myself.  If you have any suggestions on a good ready-made calendar please let me know.  If you know of any tutorials that might help me to learn how to do it myself please let me know as well.  Thanks everyone!

Link to comment
https://forums.phpfreaks.com/topic/122070-please-help-i-need-your-suggestions/
Share on other sites

Check this out, maybe it will help... Im pretty new to php myself but google is a great resource!  I have found a great deal of help and toturials just searching thru google.

 

Hope this helps

-Matt

http://www.tutorialized.com/view/tutorial/PHP-Calendar/15716

calendars are actually very easy to write people just are scared of them for some reason.

 

There are 2 parts the inputter and the outputter

 

The inputter is just a simple form that puts in the date of the event and information about it and stores it into mysql.  I hope you know how to do this if you can't that is what you need to learn first is basic mysql inserting via a html form.

 

The outputter is trickier but not super tricky.

 

First step to the outputter is to get the events for that month

a query might look like

<?php
$start_date = date("U",strtotime($_POST['start_date']));
$end_date = date("U",strtotime($_POTS['end_date']));
$q = "Select * from `events` where Date >= '".$start_date."' and Date <= '".$end_date."'";
$r = mysql_query($q) or die(mysql_error()."<br /><Br />".$q);
$i = 0;
while($row=  mysql_fetch_assoc($r)){
foreach($row as $key=>$value){
$events[$i][$key] = $value;
}
$i++;
}
?>

Now you have an array containing all the events in your date span to generate the calender we will once again envoke the mysql date function  

<?php
$month = 8;
$year = 2008;
#day of the month = $i
$i = 1;
echo "<table>
<tr>
	<td>Sunday</td>
	<td>Monday</td>
	<td>Tuesday</td>
	<td>Wednesday</td>
	<td>Thursday</td>
	<td>Friday</td>
	<td>Saturday</td>
</tr>
";
while(date("n",mktime(0,0,0,$month,$i,$year)) == $month){
#get a timestamp for today
$today = date("U",mktime(0,0,0,$month,$i,$year));
#special check for first day so we get aligned with the sunday->saturday deal
if($i == 1){
	#new week row
	echo "<tr>";
	#this is a bit tricky we are going to use a date loop to echo out the blank first days 
	for($j = 0; $j<date("w",$today);$j++){
		echo "<td> </td>";
	}
	#now we are aligned with today so we can echo out fine
}

#check if we are on a sunday if so we need to close a <tr> and start a new one
if(date("w",$today) == 0){
	echo "</tr>";
	echo "<tr>";
}

#now we can echo out today's cell
echo "<td>".date("j",$today)."<br /><ul>";
#now lets show all of today's events
foreach($events as $key=>$value){
	if($value['Date'] == $today){
		echo "<li>".$row['EventName']."</li>";
	}
}
echo "</ul></td>";
$i++;
}
echo "</tr>";
echo "</table>";
?>

 

Very simple example, the foreach loop isn't the best method a array_search would yield better load times but it still works.

Thanks guys, I'll check it out.  Maybe I'll take a few extra days and learn to build the calendar and make it work specifically for my needs.  At least I know I have great place to come for help if I get stuck on a problem.  Thanks again!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.