troubleshooting Question

Add - in a loop to first and last element.

Avatar of Jazzy 1012
Jazzy 1012 asked on
JavaScript
6 Comments1 Solution182 ViewsLast Modified:
<?php
				$counter_price = 0;
				if(mysqli_num_rows($result_meal_price_option) > 1)
			while ($row_meal_price_option = mysqli_fetch_assoc($result_meal_price_option)) {
				$counter_price ++;
				$q_price_filters = "select * from main_filters where meal_options_id = '{$row_meal_price_option['id']}'";
				$result_price_filters = mysqli_query($conn,$q_price_filters);
				$row_price_filterd= mysqli_fetch_assoc($result_price_filters);
						?>
						<span class= "deliveryItem1
							 <?php 
                    		 if($row_price_filterd["vegan"] == 'Y'){echo "vegan ";}
                    		 if($row_price_filterd["vegetarian"] == 'Y'){echo "vegetarian ";}
                    		 if($row_price_filterd["pescatarian"] == 'Y'){echo "pescetarian ";}
                    		 if($row_price_filterd["dairy-free"] == 'Y'){echo "dairy-free ";}
                    		 if($row_price_filterd["egg-free"] == 'Y'){echo "egg-free ";}
                    		 if($row_price_filterd["fish-free"] == 'Y'){echo "fish-free ";}
                    		 if($row_price_filterd["shellfish-free"] == 'Y'){echo "shellfish ";}
                    		 if($row_price_filterd["tree nut-free"] == 'Y'){echo "tree ";}
                    		 if($row_price_filterd["peanut-free"] == 'Y'){echo "peanut ";}
                    		 if($row_price_filterd["soybean-free"] == 'Y'){echo "soy ";}
                    		 if($row_price_filterd["low-total-fat"] == 'Y'){echo "total-fat ";}
                    		 if($row_price_filterd["low-saturated-fat"] == 'Y'){echo "saturated-fat ";}
                    		 if($row_price_filterd["low-cholesterol"] == 'Y'){echo "cholesterol ";}
                    		 if($row_price_filterd["low-sodium"] == 'Y'){echo "sodium ";}
                    		 if($row_price_filterd["protein(25g)"] == 'Y'){echo "protein ";}
                    		 if($row_price_filterd["calories(450)"] == 'Y'){echo "calories ";}
                    		 ?>
                    		 ">
                    		 <?php
                    		 $price_soup= $row_meal_price_option['price'];
                    		 $price_soup = number_format($price_soup/100, 2);
                    		 $price_soup = "$" . $price_soup;

                    		 
                    		 //echo($counter_price>1 ? "- ":""). $price_soup;
                    		 
                    		 //echo $price_soup;
                    		 ?>
						</span>
					
						
						<?php }
								else{
									print_r($price1);
								}
								?>

Open in new window


I have this code, how can I echo out that when I have 2 prices it echos out price1-price2, if I have 3 it echos out price1-price3, if 4 = price1-price4, so technically, price1 - the last price, how is this possible with my code?
ASKER CERTIFIED SOLUTION
Member_2_248744

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 6 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 6 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004