Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // number of products is the count of $pizza
- $numb_products = count($pizza);
- $size_string = "";
- // loop printing info about pizzas in table
- for ($i = 0; $i < count($pizza); $i++) {
- if (empty($rawr)) {
- foreach ($pizza[$i]['size'] as $k => $s) {//$pizza[$i]= hand tossed/crunchy/pan ['size'] is beggining the loop
- //when written ex: hand tossed_small
- $size_post = $i . "_" . $k;
- //creating radio button for each pizza type
- $size_string .= "<input type=radio name='size' value='$size_post'"; //note that the input is still open
- //creating a $_POST['size'] for the selected size. $i=HT/TC/PAN_$k=S/M/L/XL
- $size_string .= isset($_POST['size']) ? ($_POST['size'] == $i . "_" . $k ? " checked='checked'" : "") : "";
- //because of $k=>$s $k now equals $s so $s['name']."($".$s['price'].")<br>" grabs the size that was selected and its corresponding price
- $size_string .= ">"/*input closes here*/ . $s['name'] . " ($" . $s['price'] . ")<br>";
- //if there are errors they would print here
- if (isset($errors['size'][$i])) {
- //if errors, print in 8px red font
- $size_string .= "<span style='font-style:italic;font-size:8px;color:red;'>{$errors['size'][$i]}</span>";
- }
- }
- // format table with printf
- printf('
- <tr>
- <td><img alt="Small" id="lightboxImage"
- style="width: 119px; height: 88px;"
- src="http://i.imgur.com/%s"
- height="300" width="300"></td>
- <td style="text-align: center;">%s</td>
- <td style="text-align: left;">' . $size_string . '</td>
- </tr>
- ', $pizza[$i]['image'], $pizza[$i]['type'], $pizza[$i]['price']);
- $size_string = "";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement