Get a nice clean LAMP (Linux, Apache, MySQL, PHP) or WAMP (Guess) setup and start typing:
Step one is to learn about breaking in/out of PHP and regular HTML as highlighted above. Then visit PHP: Hypertext Preprocessor and start doing stuff.
General programming things to learn (before you even touch database stuff) should be as follows:
- Variables ( Storing data for use later ) and Types ( There IS a difference between an Integer, Float and Strings, but PHP makes it quite transparent.
- Arrays (Lots of variables stored in 'one variable' as a sort of list)
- Operators (Bitwise, Logical and Mathematical e.g. comparing variables or adding things)
- Loops: for, while, foreach
- Functions ( Segments of code that can be re-called over and over ).
For what it's worth, I'm SOLID at PHP but I never ever picked up a book on it but you should learn to walk before you can run
Doing is more important than reading because the MORE you do it, the more you learn, much faster than reading books (php.net is the ultimate reference for the language, better than any book IMO). So sit down and start coding.
Below is a little tutorial PHP I wrote for a colleague, you can work on that to learn some basic programming stuff if you need direction. It has a few things wrong with it, and has tasks to do. It's worth reading the code over to get a feel for it, it's not too hectic, but does have a few gotchas.
Let us know how you get on and if you need any tips :P
// TASK! figure out why the PHP program doesnt work!
// what if the file didn't exist?
// could we check if it did first?
// think about the function at
// if the file doesn't exist, kick up an error message
$filehandle = fopen($filename,"r"); // opens the file for reading
$filecontents = ""; // empty text
// use a while loop to keep grabbing data from the file
while(!feof($filehandle) ) // feof() checks to see if we're at the end of the file, what do you think the ! operator is for?
$filecontents .= fgets($filehandle); // gets a line from the file. What do you think .= does in regards to strings?
fclose($filehandle); // close the file
return $filecontents; // return to the calling function the text we have loaded
$csvdata = get_file($filename); // call the above function to get the CSV data
$data_array = split(",", $csvdata); // split the data up using , as a delimiter
// using temporary variables and loops
// try sorting the data into alphabetical order
// try following a bubble sort algorithm to do this
// below has been started for you
// try to finish it off
// this function may help you:
// comment this function describing what each bit does
// so you understand how the sort works.
// DO NOT use PHP's in-built sorting functions to do this!
// this will teach you the process of structuring data and moving it around.
function BubbleSort( &$items )
$temp = "";
$size = count( $items );
for( $i = 0; $i < $size-1; $i++ )
for( $j = 0; $j < $size - 1 - $i; $j++ )
// if( ... )
// in BubbleSort( &$items )
// any idea what the & is used for?
// think about the data, and the fact that we don't
// return any values in BubbleSort
// how do you think the memory is being accessed?
// the following may give you an idea:
////////////// PROGRAM STARTS HERE!! ///////////////////
$data = read_csv("users.doc"); // get the data from the CSV file
// count() returns the number of elements in an array
// any ideas what this loop does?
echo $data[$i] . "<br>";
// output the sorted data
echo "<h2>Sorted Data</h2>";
echo $data[$i] . "<br>";
// implement a quicksort algorithm in order to
// speed up processing time!
// what are the up-sides and down-sides of both algorithms?