Wrox Programmer Forums
|
BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5
This is the forum to discuss the Wrox book Beginning PHP4 by Wankyu Choi, Allan Kent, Chris Lea, Ganesh Prasad, Chris Ullman; ISBN: 9780764543647
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 3rd, 2004, 04:45 AM
Registered User
 
Join Date: May 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 5

Hi

In the book I have "Beginning PHP4" I found an error in the section "Iterating through an array" THe code for the states.php errored when I tried it. I checked the code and then downloaded the code for the page from the Wrox site. Still the error occured. Ihave amended the code to work as follows:

<body>

<form action="capitals.php" method="post">
<p>What state do you want to know the capital of?

    <?php
echo "<select name=State>";
$StatesOfTheUSA = array (1 => "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming");
for ($counter=1; $counter<51; $counter++) {
   echo"<OPTION>$StatesOfTheUSA[$counter]</OPTION>";
}
echo "</SELECT><BR><BR>";
for ($counter=1; $counter<51; $counter++) {
   echo"<INPUT TYPE=HIDDEN NAME='HiddenState[]' VALUE='$StatesOfTheUSA[$counter]'>";
}
?>
</p>
<p>
  <input type="submit" name="Submit" value="Submit" />
</p>
</form>

</body>

the code from the book, copied from the Wrox web site is:

<BODY>
<FORM ACTION="capitals.php" METHOD=POST>
What state do you want to know the capital of?
<SELECT NAME=State>
<?php

$StatesOfTheUSA = array (1 => "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming");
for ($counter=1; $counter<51; $counter++) {
   echo"<OPTION>$StatesOfTheUSA[$counter]</OPTION>";
}
echo "</SELECT><BR><BR>";
for ($counter=1; $counter<51; $counter++) {
   echo"<INPUT TYPE=HIDDEN NAME='HiddenState[]'VALUE='$StatesOfTheUSA[$counter]'>";
}
echo "<INPUT TYPE=SUBMIT></FORM>";
?>
</BODY>

I am a keen to learn PHP which is my first attempt at learning a programming language. My background is in the Printing Trade. Due to the advance in technologies over the years I found I needed to learn more and more about working with computer software. This next step into programming seems a natural progression.

Cheers
LApidos








Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 2 - End of chapter exercises whizzkid1892 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 July 30th, 2008 12:02 PM
chapter 7 - chapter 11 pelopito BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 3 January 6th, 2008 11:40 AM
Generics chapter 12 difficult chapter i found ...? Larryz C# 2005 1 July 4th, 2007 09:40 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.