What your looking for is variable variables. The trick is to use what I like to call the squigley braces 🙂 So in your example, we would use:
for ( $k = 1 ; $k <= $hdd_number ; $k++) {
$insert_hdd = "insert into hdd values (NULL,'".${'hdd_size'.$k}."','$comp_id','".${'hdd_type'.$k}."')";
$hdd_result = mysql_query($insert_hdd);
}
Notice how we use the quotes and the concatonator (the .) inside of the braces after the $. Basically, PHP just uses that as a string and then uses the variable of that name in its place.
For more information, you can look here:
http://www.php.net/manual/en/language.variables.variable.php
Hope that helps!
Chris King