70 likes | 87 Views
Learn general rules and key concepts of PHP development. Explore an example code snippet and understand the basics of HTML and PHP formatting. Get insights into creating forms, tables, and input elements in PHP coding.
E N D
IS 118 Introduction to Development Tools Week 1 part 2
Some general rules and things to know about PHP • Example on Pg 13 – Listing 1.1 • Html code is enclosed in angles < >, PHP uses the same format • In general you use lower case for commands • <table border=“0”> - note the double quotes • This means that it is a literal, a value being supplied • Each command that is started has to be ended • Eg < table > has to end with </table> • You use a plain text editor such as notepad (within windows) to write your code. You can not use MS Word or Wordpad
Listing 1.1 • Let’s look a bit at the code • So < form action=“processorder.php” method=“post”> • Means this is a form we are creating, named processorder.php and we are going to post it or show it • <table border=“0” means create a table that I am defining • < tr bgcolor=“#cccccc”> create a row in the table • <td width=“150”>Item</td> this creates a column in the row, size 150 and put the text Item in it., end the definition with </td> • <td width=“15”>Quantity</td> create a second column, width 15, put Quantity in it • </tr> end of the row definition
Listing 1.1 continued • Next row <tr> is all that is needed because the widths are known • <td>Tires</td> put tires in the column • <td align=“center”><input type=“text” name=“tireqty” size=“3” maxlength=“3” /></td> • </tr> • This one is complicated looking isn’t it – • So lets take it apart:
Listing 1.1 continued • <td align=“center”><input type=“text” name=“tireqty” size=“3” maxlength=“3” /></td> • This column is going to get input, we know this because it says input type=“text” • The input will be centered • The name of the input is tireqty • The size of the input is 3 and the maximum size is 3
Listing 1.1 continued • Last thing for this listing is: • <tr> • <td colspan="2" align="center"><input type="submit" value="Submit Order"></td> • </tr> • </table> end definition of the table • </form> end definition of the form
<td colspan="2" align="center"><input type="submit" value="Submit Order"></td> • Colspan=“2” says this row will span both columns making it like one • The contents of the column will be centered • The input type is “submit” • With a value of “Submit Order” • This creates a submit button