Jump to content

MAJOR PHP HELP with online Schedule


dubc07

Recommended Posts

In this program I'm trying to pull user's info that has been submited to mysql

to apply it to this script.

 

However i cannot figure out how to apply multiple  user's info from mysql to array into the schedule.

it will only pull one user from the database and that's all. I believe it has something to do with the array's

closing ).

below is the link and what it looks like with just one user pulled from database.

 

http://x.crabtreeaircraft.com/nutts.php

 

Here is the code

<?php

require_once('require_once.php');

mysql_select_db("databads"); 



   //display all the news
   $result = mysql_query("select * from rentme order by plane"); 
   
   //run the while loop that grabs all the news scripts
   while($r=mysql_fetch_array($result)) 
   { 
      //grab the title and the ID of the news
      $name=$r["name"];//take out the title
      $time=$r["time"];//take out the id
  $plane=$r["plane"];
  $intrv=$r["intrv"];
  $color=$r["color"];
  $type=$r["$type"];
  


$tilt = array(
		// Adds a class at 12pm (1200 hours)
		$time =>array(
			"html" => "<b>$name</b><br>$type", // Display 'Phsychology: Room 404'
			"style" => "background-color: $color", // use style property to change the background color
			"interval" => $intrv // set the interval for 2hrs 
			),);





$first = array($plane =>$tilt);

$planes = $first;



echo $planes;

}
$classes_arr = $planes;




$options = array( 
		"row_interval" => 30, // set the schedule to display a row for every /2hr
		"start_time" => 700, // schedule start time  (10am)
		"end_time" => 2200,   // schedule end time (10pm)

		"title_style" => "font-family: verdana; font-size: 14pt;", // css style for schedule title
		"time_style" => "font-family: verdana; font-size: 8pt;",  // css style for the time cells
		"dayheader_style" => "font-family: verdana; font-size: 10pt;", // css style for the day header cells

		// default css style for the class cells. Eachs tyle can be overridden using the "style" property of each class
		// see schedule.inc.php for details.
		"class_globalstyle" => "background-color: #EBEBEB; font-family: verdana; font-size: 8pt; text-align: center;", 
);



	// if no row interval set or is zero, use 30mins
	if ( intval($options["row_interval"]) == 0 ) $options["row_interval"] = 30;	

	// define start time as 8am if not set
	if ( ! isset($options["start_time"]) ) {
		$options["start_time"] = 700;
	}
	else {
		// change to the nearest row interval hour down.
		$time_hour = ($options["start_time"] - $options["start_time"] % 100) / 100; 
		$time_min = $options["start_time"] % 100;

		$time_totalmins = $time_hour * 60 + $time_min;

		if ( $time_totalmins % $options["row_interval"] > 0) $time_totalmins = $time_totalmins - $time_totalmins % $options["row_interval"];
		$options["start_time"] = ($time_totalmins - $time_totalmins % 60) / 60 * 100 + $time_totalmins % 60;

	}


	// define end time as 10pm if not set
	if ( ! isset($options["end_time"]) ) {
		$options["end_time"] = 2200;
	}
	else {
		// change to the nearest row interval hour down.
		$time_hour = ($options["end_time"] - $options["end_time"] % 100) / 100; 
		$time_min = $options["end_time"] % 100;

		$time_totalmins = $time_hour * 60 + $time_min;

		if ( $time_totalmins % $options["row_interval"] > 0) $time_totalmins = $time_totalmins - $time_totalmins % $options["row_interval"];
		$options["end_time"] = ($time_totalmins - $time_totalmins % 60) / 60 * 100 + $time_totalmins % 60;

	}

	$days_arr = array( "plane1", "plane2", "plane3", "instructor", "instructor", "instructor");
	$days_norow = array(0, 0, 0, 0, 0, 0, 0 );


	$html = "<table width=\"100%\" bgcolor=\"#FFFFFF\" cellspacing=\"2\" cellpadding=\"0\">\n";

	// output title if set in $options.
	if ( isset($options["title"]) ) {
		$cell_style = "background-color: #FFCC00; color: #0099CC;"; // default title style 
			$cell_style .= $options["title_style"];

		$html .= "	<tr>\n		<th colspan=\"8\" style=\"$cell_style\">".$options["title"]."</th>\n	</tr>\n";
	}

	$cell_style = "background-color: #0099CC; color: #FFFFFF;"; // default day header style
	$cell_style .= $options["dayheader_style"];

	$html .= "	<tr style=\"$cell_style\">\n		<th> </th>\n";
	foreach ($days_arr as $day){
		$html .= "		<th>$day</th>\n";
	}
	$html .= "	</tr>\n";

	$cur_time = $options["start_time"];
	while ($cur_time < $options["end_time"]) {
		$format_time = date("g:ia", strtotime(substr($cur_time, 0, strlen($cur_time) - 2).":".substr($cur_time, -2, 2)));

		$cell_style = "background-color: #FF9900; color: #FFFFFF;"; // default time cell style

		$cell_style .= $options["time_style"];			

		$html .= "	<tr bgcolor=\"#ffffff\">\n		<td align=\"right\" width=\"2%\" style=\"$cell_style\"><b>$format_time</b></td>\n";

		for ($cur_day = 0; $cur_day < 6; $cur_day++) {

			// if flag is set not to print any row for the next
			// row (since a class spans more than one row), then
			// continue.
			if ($days_norow[$cur_day] > 0) {
				$days_norow[$cur_day]--;
				continue;
			}
		$cell_style2 = "bgcolor=\"#EBEBEB"; // default time cell style
		//select which database you want to edit

				 // check if there is a class during this day/time
			if ( isset($classes_arr[$cur_day][$cur_time]) ) {

					$class_interval = intval($classes_arr[$cur_day][$cur_time]["interval"]);
					if ( $class_interval == 0 ) $class_interval = 60; // default interval is 60mins

					// round to nearest interval
					$class_span = intval($class_interval / $options["row_interval"]);

					// flag that for the next $class_span rows, we should not print a cell
					$days_norow[$cur_day] += $class_span - 1;		

				    if ( isset($classes_arr[$cur_day][$cur_time]["style"]) )
						$cell_style = $options["class_globalstyle"]."; ".$classes_arr[$cur_day][$cur_time]["style"];
					else
						$cell_style = $options["class_globalstyle"];

					$html .= "		<td width=\"14%\" rowspan=\"$class_span\" style=\"$cell_style\">".$classes_arr[$cur_day][$cur_time]["html"]."</td>\n";

			}		
			else {
					$html .= "		<td width=\"14%\ style=\"$cell_style2\"> </td>\n";			


			}


		}


		$html .= "	</tr>\n";

		$cur_time += $options["row_interval"]; // increment to next row interval
		if ($cur_time % 100 >= 60) $cur_time = $cur_time - $cur_time % 100 + 100;
	};



	$html .= "</table>\n";

	echo $html;





?>

Link to comment
https://forums.phpfreaks.com/topic/115314-major-php-help-with-online-schedule/
Share on other sites

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.