Click here to Skip to main content
15,886,362 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
AnswerRe: supplied argument is not a valid Image resource Pin
fly9046-Aug-09 20:45
fly9046-Aug-09 20:45 
GeneralRe: supplied argument is not a valid Image resource Pin
Reptar06-Aug-09 21:20
Reptar06-Aug-09 21:20 
Answerre Pin
Fuad Abu Sameer4-Aug-09 3:12
Fuad Abu Sameer4-Aug-09 3:12 
QuestionFLV Encoding Pin
vasanth arivali4-Aug-09 0:35
vasanth arivali4-Aug-09 0:35 
AnswerRe: FLV Encoding Pin
Marc Firth4-Aug-09 2:42
Marc Firth4-Aug-09 2:42 
AnswerRe: FLV Encoding Pin
enhzflep4-Aug-09 2:56
enhzflep4-Aug-09 2:56 
QuestionHelp creating an Array Pin
Reptar03-Aug-09 18:16
Reptar03-Aug-09 18:16 
AnswerRe: Help creating an Array Pin
enhzflep3-Aug-09 20:47
enhzflep3-Aug-09 20:47 
Yup, it sure is. Compared to any of the strongly typed languages, it's a snap.
Been working on a student timetable program. Only problems are that it's not an SQL database that contanis the student data, nor is the data I want sorted.

To do so, I had to create a class to hold my data and a compare function to be used when sorting the data.

Here's a snippet:
class myActivity
{
	var $name;				// (string) activityName
	var $teacher;			// (string) teacher Name
	var $size;				// (int) num pupils
	var $location;			// (string) room location
	var $day;				// (int) 0-6
	var $startTime;			// (int) minutes past midnight
	var $duration;			// (int) number of minutes this clas goes for
	var $isStaff;			// (bool) is for a staff member or not (staff get class sizes, all others get techer name)

	function myActivity($name, $teacher, $size, $location, $day, $startTime, $duration, $isStaff)
	{
		$this->name = $name;
		$this->teacher = $teacher;
		$this->size = $size;
		$this->day = $day;
		$this->startTime = $startTime;
		$this->duration = $duration;
		$this->isStaff = $isStaff;
		$this->location = $location;
	}

	// compare function. Takes into account both day of week and time of day if day of week is the same
	function _cmpDayTimeAsc($item1, $item2)
	{
		if ($item1->day == $item2->day)
		{
			return ($item1->startTime < $item2->startTime) ? -1: 1;
		}
		return ($item1->day < $item2->day) ? -1 : 1;
	}
}


To use, it's very, very simple.

1. Declare the array
2. Add elements to the array
3. Sort the array (if needed)
4. Use as required.

// declare array to hold list of activites, ready for sorting
$actArray = array();

// just add items to the array like so
$actArray[] = new myActivity($curName, $teacherName, $numStudentsInClass, $curLocation, $myDay, $startMin, $curDuration, $isStaff);

// finally sort the array. My compare function ensures that when the classes for the week are displayed, they are displayed in the order that they occur.
$boolDidSort = usort($actArray, array('myActivity', '_cmpDayTimeAsc'));

AnswerRe: Help creating an Array Pin
Marc Firth4-Aug-09 2:44
Marc Firth4-Aug-09 2:44 
AnswerRe: Help creating an Array Pin
Reptar04-Aug-09 12:09
Reptar04-Aug-09 12:09 
QuestionHow write in perl ? Pin
udch3-Aug-09 3:31
udch3-Aug-09 3:31 
AnswerRe: How write in perl ? Pin
Marc Firth9-Aug-09 22:41
Marc Firth9-Aug-09 22:41 
AnswerRe: How write in perl ? Pin
Dengjin_CN15-Oct-09 18:27
Dengjin_CN15-Oct-09 18:27 
Questionserch help for llinux 's config files of php and apache Pin
mark_zxy2-Aug-09 23:58
mark_zxy2-Aug-09 23:58 
AnswerRe: serch help for llinux 's config files of php and apache Pin
Jimmanuel3-Aug-09 9:33
Jimmanuel3-Aug-09 9:33 
QuestionPHP Hello world Example Pin
RachelSo1-Aug-09 15:56
RachelSo1-Aug-09 15:56 
AnswerRe: PHP Hello world Example Pin
udch1-Aug-09 22:12
udch1-Aug-09 22:12 
GeneralRe: PHP Hello world Example Pin
RachelSo3-Aug-09 18:06
RachelSo3-Aug-09 18:06 
AnswerRe: PHP Hello world Example Pin
Marc Firth4-Aug-09 2:49
Marc Firth4-Aug-09 2:49 
GeneralRe: PHP Hello world Example Pin
Muammar©22-Aug-09 3:28
Muammar©22-Aug-09 3:28 
GeneralRe: PHP Hello world Example Pin
Marc Firth23-Aug-09 21:43
Marc Firth23-Aug-09 21:43 
Question[Message Deleted] Pin
udch31-Jul-09 22:39
udch31-Jul-09 22:39 
AnswerRe: How to write this code in php ? Pin
senorbadger3-Aug-09 3:48
senorbadger3-Aug-09 3:48 
GeneralRe: How to write this code in php ? Pin
udch6-Aug-09 9:02
udch6-Aug-09 9:02 
QuestionHow to copy all file from on directory to another Pin
udch31-Jul-09 10:00
udch31-Jul-09 10:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.