petbar
-
Posts
7 -
Joined
-
Last visited
Never
Posts posted by petbar
-
-
$showoptions=$_POST['optionslist']; foreach( $showoptions as $key => $value){ $justprice =explode (',', $value); foreach( $justprice as $value ) { $sum += $value; } } $optionsprice=$sum;
Thanks guys for all the help I got it
-
May I expand my question ?
$showoptions=$_POST['optionslist']; $N = count($showoptions); for($i=0; $i < $N; $i++) { $showoptionsParts = explode(',',$showoptions[$i] ); $optionsname = $showoptionsParts[0]; $optionsprice = $showoptionsParts[1]; echo $optionsprice."<br />"; }
Works great and returns The selected option prices. What is the best way for me to SUM the items to use further down the page. I was under the impression $showoptionsParts[1] was an array but I guess I'm incorrect AGAIN
-
That make a ton of sense
Thank you will give it a try
-
Array ( [0] => Lock and Unlock,29.00 [1] => Trunk Pop,19.00 )
so I have been trying
$showoptionsParts = explode(',',$showoptions ); $optionsname = $showoptionsParts[0]; $optionsprice = $showoptionsParts[1]; echo "here".$optionsprice;
even before you suggested. That is what is driving me nuts.
again thanks for you time
-
$showoptionsParts = explode(',',$showoptions ); $optionsname = $showoptionsParts[0]; $optionsprice = $showoptionsParts[1]; echo "here".$optionsprice;
Still nothing returned for $optionsprice.
Would it be an issue if there are spaces in $optionsname ? example ( Lock and Unlock ). I have to be doing something really dumb that I'm just not catching
Thanks for the reply
-
Need some help with something I have not done before.
I have a dynamic checkbox set up to accept userinput then post $optionsname,$optionsprice.
echo "<li><input type=\"checkbox\" name=\"optionslist[]\" value=\"$optionsname,$optionsprice\" /> $optionsname - $ $optionsprice - $optionsdisc</li>";
So far no problem
$showoptions=$_POST['optionslist']; if(empty($showoptions)) { echo("You didn't select any options."); } else { $N = count($showoptions); echo("<strong>You selected $N options:</strong> "); for($i=0; $i < $N; $i++) { echo("<li>".$showoptions[$i] . "</li>"); } }
Can someone tell me how to explode $showoptions into $optionsname,$optionsprice again.
Thanks for any help in advanced.
explode question
in PHP Coding Help
Posted
thank you again starting to clean up now.