Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.30 KB | None | 0 0
  1. // number of products is the count of $pizza
  2.                     $numb_products = count($pizza);
  3.                     $size_string = "";
  4. // loop printing info about pizzas in table
  5.                     for ($i = 0; $i < count($pizza); $i++) {
  6.                         if (empty($rawr)) {
  7.                             foreach ($pizza[$i]['size'] as $k => $s) {//$pizza[$i]= hand tossed/crunchy/pan ['size'] is beggining the loop
  8.                                 //when written ex: hand tossed_small
  9.                                 $size_post = $i . "_" . $k;
  10.                                 //creating radio button for each pizza type
  11.                                 $size_string .= "<input type=radio name='size' value='$size_post'"; //note that the input is still open
  12.                                 //creating a $_POST['size'] for the selected size. $i=HT/TC/PAN_$k=S/M/L/XL
  13.                                 $size_string .= isset($_POST['size']) ? ($_POST['size'] == $i . "_" . $k ? " checked='checked'" : "") : "";
  14.                                 //because of $k=>$s $k now equals $s so $s['name']."($".$s['price'].")<br>" grabs the size that was selected and                                    its corresponding price
  15.                                 $size_string .= ">"/*input closes here*/ . $s['name'] . " ($" . $s['price'] . ")<br>";
  16.                                 //if there are errors they would print here
  17.                                 if (isset($errors['size'][$i])) {
  18.                                     //if errors, print in 8px red font
  19.                                     $size_string .= "<span style='font-style:italic;font-size:8px;color:red;'>{$errors['size'][$i]}</span>";
  20.                                 }
  21.                             }
  22.                             // format table with printf
  23.                             printf('
  24.                             <tr>
  25.                                 <td><img alt="Small" id="lightboxImage"
  26.                                         style="width: 119px; height: 88px;"
  27.                                         src="http://i.imgur.com/%s"
  28.                                         height="300" width="300"></td>
  29.                                 <td style="text-align: center;">%s</td>
  30.                                 <td style="text-align: left;">' . $size_string . '</td>
  31.                             </tr>
  32.                             ', $pizza[$i]['image'], $pizza[$i]['type'], $pizza[$i]['price']);
  33.                             $size_string = "";
  34.                         }
  35.                     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement