Looking at your earlier posts I would suggest that yes it should be ListBox1 and not Course1.
Also change the foreach line to read foreach (array($_POST['ListBox1'], $_POST['ListBox2']) as $val) The $_ is only used for the Automatic Global Variables. Regards Rob Howard -----Original Message----- From: Wade [mailto:[EMAIL PROTECTED]] Sent: Tuesday, 14 January 2003 5:56 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-WIN] initialize variables 01132003 2251 CST Thanks Robert. I was close before. I had tried something similar but just didnt get it straight. Have another question. I made the change to the code and the result is: Your order was for the following: Entree: "" Dessert: "Ice Cream ($2)" TOTAL BILL = $"0" Now, for all variables do I put $_ before the variable? The rest of the code does not have this? But, That does not explain why the Course1 data was not displayed. Is it instead of Course1 it should be ListBox1? Wade Robert P Howard wrote: > Hi Wade, > > This is what you should have put in the Echo Lines > > echo 'Entree: "' . $_POST['Course1'] . '"<br>'; > echo 'Dessert: "' . $_POST['ListBox2'] . '"<br><br>'; > > the $_POST variable is set as an array with the names of each of the POST > variables as Keys to the array. As such $_POST['Course1'] is the > replacement of $Course1. > > Keep on trying. > > Rob Howard > -----Original Message----- > From: Wade [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, 14 January 2003 5:13 PM > To: [EMAIL PROTECTED] > Subject: Re: [PHP-WIN] initialize variables > > > 01132003 2203 CST > > I thought I was starting to get it until I got to the last section. > > Original code from the book: > > <?php > $total = 0; > > echo "Your order was for the following:<br><br>"; > echo "Entree: $Course1<br>"; > echo "Dessert: $ListBox2<br><br>"; > > foreach (array($Course1, $ListBox2) as $val) > { > if (ereg("[0-9]+", $val, $reg)) $total += $reg[0]; > } > echo "TOTAL BILL = $" . $total . "<br>"; > ?> > > I was brave and tried to make many changes but none worked. This is > where I ended up: > > <?php > $total= 0; > > echo 'Your order was for the following:<br><br>'; > echo 'Entree: "' . $_POST . $Course1 . '"<br>'; > echo 'Dessert: "' . $_POST . $ListBox2 . '"<br><br>'; > > foreach (array($Course1, $ListBox2) as $val) > { > if (ereg('[0-9]+', $val, $regs)) $total += $regs[0]; > } > > echo 'TOTAL BILL = $"' . $total . '"<br>'; > ?> > > The output for this last code is: > > Your order was for the following: > > Entree: Array > Dessert: Array > > TOTAL BILL = $"0" > > Enlighten me. Im trying hard to understand where to put things together. > > Thanks > > Wade > > > > > Sean Malloy wrote: > >>String concatenation? >> >>Its a way ogf combining strings into one. >> >>$string = 'Hello'; >> >>$string = $string . ' World'; >> >>echo $string; >> >>would output 'Hello World' >> >>-----Original Message----- >>From: Wade [mailto:[EMAIL PROTECTED]] >>Sent: Tuesday, 14 January 2003 4:02 PM >>To: [EMAIL PROTECTED] >>Subject: Re: [PHP-WIN] initialize variables >> >> >>01132003 2059 CST >> >>Sean, >> >>Thats a new one for me. In the line below, what does the " ' . >>$Entrees[0] . ' "> do? >> >>The " . ", do they have some value or do they negate something? >> >> echo '<option value="' . $Entrees[0] . '">' . $Entrees[0] . '</option>'; >> >> >>Wade >> >> > > > -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ##################################################################################### This e-mail message has been scanned for Viruses and Content and cleared by MailMarshal ##################################################################################### -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php