Jump to content
Larry Ullman's Book Forums

old.graham

Members
  • Posts

    27
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by old.graham

  1. Sorry to be so long in coming back, but I got waylaid by a project for a client that just grew and grew. Here is the code I wrote in answer to Chapter1 Review and Pursue. Hope this helps. Should be another installment coming up once I put my PHP hat on again. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Review Chapter 1</title> </head> <body> <?php #review page34 chapter1 $number = 10.111; //some variables $number2 = 20.2; $number3 = 30.3; $total = $number*$number2*$number3; //do things with variables $total1 = number_format($total, 2); //format the result to 2 decimal places define('NAME', 'Muggins'); //some constants define('VALUE', 'Number1'); define('VALUE2', 'Number2'); define('VALUE3', 'Number3'); //bit of HTML: a table echo '<table border="1"> <tr> <td colspan="3" border="1">' . NAME . '</td> <tr> <td>' . VALUE. '</td><td>' . VALUE2 . '</td><td>' . VALUE3 . '</td> </tr> <tr> <td>' . $number . '</td><td>' . $number2 . '</td><td>' . $number3 . '</td> </tr> </table>'; echo "\n<hr /><br />Multiply all the numbers to get a total of: <b>$total1</b>"; echo "\n<hr /><br />" . 'The number rounded up (ceil): <b>' . ceil($total). '</b>'; echo "\n<hr /><br />" . 'The number rounded down (floor): <b>' . floor($total). '</b>'; ?> </body> </html>
  2. I bought your new book recently after the cover on edition2 started to fall apart. You may be pleased to know that the book helped me (and the group I worked with) to gain a very high mark (over 90%) in our final BSc degree project a few years ago. I like the review and pursue sections at the end of each chapter since I quickly find out whether what I have read has actually sunk in, although I tend to start exploring coding possibilities and lose focus on the original questions. That said, although all my php, css etc always works (eventually!), I often wonder if there were better ways of completing the exercises than the methods I have used. Given the nature of coding, there is often no right or wrong way to solve problems, but perhaps worked examples might be useful? Since this would mean a lot more work for you, maybe others would feel able to offer solutions to the questions? Perhaps set up as Answers to Chapter x?
×
×
  • Create New...