Grabbing data from one table and inserting it into another

hi guys im a student studying sql and php

im wondering how to Grab data from one table and inserting it into another table

i have already made a code that displays student order by average desc

here is my code
[php]$i = 1;
while($row = mysql_fetch_assoc($result)) {
echo “

” . $row[‘studentID’] . “ ” . $row[‘lastname’] . ", " . $row[‘firstname’] . “ ” . $row[‘average’] . “ ” . $row[‘date’] . “ ”;
$sql = mysql_query("CREATE TABLE section(studentID int, lastname text, firstname text)");

// end and create a new table every 2 rows
if ($i % 2 === 0) {
	echo "</table>";
	echo "<table cellpadding=2 border=1><tr><td>StudentID</td><td>Name</td><td>average</td><td>date</td></tr><br />";
	

}
$i++;

}[/php]

Maybe I am missing something in your question but at a high level you want to

1: Use a query to read the record from your first table.
2: Store the values in an array or variable
3: Write those stored values to the second table.

yes that is what i want to do, im sorry my grammar is poor :frowning:
im an asian

Sponsor our Newsletter | Privacy Policy | Terms of Service