Here is a simplified version.
PHP Code:
if ($mysidia->input->post('buy')) {
$chosenOption = (int) $mysidia->input->post('myList');
for ($i = 1; $i < $chosenOption; $i++) {
$mysidia->db->insert('raffle_tickets', array(
'owner' => $mysidia->user->username
));
}
}
It casts the type of $chosenOption to an integer. Like explained above the for loop just iterates over the block of code until the condition is false; i.e. $i (the counter) is greater than $chosenOption.