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);
								}
								?>

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
Slick812

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

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros