inserting data from one table to another
Posted: Tue Jan 13, 2009 7:08 am
hello. in table "a" i have 100 rows of data. i want to take 10 of these rows at random (this part i can do) and put some of the data into table "b". my problem is if i do the while loop for going through the 10 rows from "a" ...... while($row = mysql_fetch_array($result)) ....... then how can i upload data from certain fields to "b" in the same while loop. it means not having finished with one $result="mysql_query" (for data retrieval from "a" before opening another for data insertion to "b", thus canceling the first. or am i misunderstanding that?
or is there a different way to do this? i thought about a way to convert the "a" data into variables but then i ran into problems with variables inside variables. if one field is called field_1 for example, i would need the variables to be called field_1_1, field_1_2, field_1_3 etc etc.
can anyone help?
p.s. it possibly doesn't complicate things but it's not always as stated above 10 results i need. the figure 10 is a variable called $maxwords and can be 5, 10, 20, 30 or 40.
or is there a different way to do this? i thought about a way to convert the "a" data into variables but then i ran into problems with variables inside variables. if one field is called field_1 for example, i would need the variables to be called field_1_1, field_1_2, field_1_3 etc etc.
can anyone help?
p.s. it possibly doesn't complicate things but it's not always as stated above 10 results i need. the figure 10 is a variable called $maxwords and can be 5, 10, 20, 30 or 40.