Hi everyone :)

I have created a kind of catalogue thing but when users purchase the item they have the option of how many they want, although at the moment I have been doing if statements e.g.

$amount = $_POST[amount];
if($amount ==1){ 
$insert = mysql_query BLA BLA
}elseif($amount ==2){ 
$insert = mysql_query BLA BLA
$insert = mysql_query BLA BLA
}

I know there has to be a way that using the posted amount to times ( * ) the query of the insert, I was wondering how I could perhaps do this therefore it would shorten my code and help tidy it up a bit :)

Thanks in advance!

$amount = $_POST[amount];
$i = 0;
while ($amount > $i) {
$insert = mysql_query BLA BLA
$i++
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.