requestcode
04-06-2005, 08:01 PM
I am developing a small Data Entry application that has a form with multiple lines where each line will represent a record on the database(MySql). Each line has a card number, cost center, hourly rate, earnings type, hours
I have set up the element names so that for instance card number for the first line is card_num_1, second line card_num_2, etc. When they submit the form I will need to take each line (record) and update the data base. To cut down on the amount of coding that I have to do to access each line and create a record to update the table I found the function eval(). The following is a sample of what I used to test it:
<?php
$my_name_1="Micky Mouse";
$my_name_2="Donald Duck";
$my_name_3="Minnie Mouse";
for($i=1;$i<=3;$i++){
$my_name="\$my_name"."_$i";
eval("\$my_name = \"$my_name\";");
print "$my_name<br>";
}
?>
I used the above code to figure out how the eval() function worked. This method will work for me, but not sure if it is the best way. Does anyone have any other suggestions that would be better than using eval().
I have set up the element names so that for instance card number for the first line is card_num_1, second line card_num_2, etc. When they submit the form I will need to take each line (record) and update the data base. To cut down on the amount of coding that I have to do to access each line and create a record to update the table I found the function eval(). The following is a sample of what I used to test it:
<?php
$my_name_1="Micky Mouse";
$my_name_2="Donald Duck";
$my_name_3="Minnie Mouse";
for($i=1;$i<=3;$i++){
$my_name="\$my_name"."_$i";
eval("\$my_name = \"$my_name\";");
print "$my_name<br>";
}
?>
I used the above code to figure out how the eval() function worked. This method will work for me, but not sure if it is the best way. Does anyone have any other suggestions that would be better than using eval().