PrivateUser
PrivateUser

Reputation: 4524

php for loop breaking site layout

This is my old code

$xml .=  '<select style="width:80%;margin-bottom:10px;" name="qty" class="input-text qty" id="qty">';
    foreach ($prices as $price) {
    $xml .= '<option value="'.$price['price_qty'].'">'.$price['price_qty'].' pieces - '.$price['formated_price'].' each</option>';
    }
$xml .= '</select>';

I replaced that with this code

$xml .=  '<select style="width:80%;margin-bottom:10px;" name="qty" class="input-text qty" id="qty">';
    for ($i=1;$i<=100;$i++) {
    $xml .= '<option value="'.$i.'">'.$i.'</option>';
    }
$xml .= '</select>';

For some reason for loop breaking my grid layout. Can someone tell me whats wrong with my code?

Upvotes: 0

Views: 70

Answers (1)

Dave
Dave

Reputation: 1069

Here is the correct code : $i was overlapping with other parts of your script

$xml .=  '<select style="width:80%;margin-bottom:10px;" name="qty" class="input-text qty" id="qty">';
    for ($c=1;$c<=100;$c++) {
    $xml .= '<option value="'.$c.'">'.$c.'</option>';
    }
$xml .= '</select>';

Upvotes: 2

Related Questions