Jump to content

write from php.


grlayouts

Recommended Posts

ok if i have the code
Code:

include("config.php");
$result =  mysql_query("select * from players WHERE id > 1 order by level desc limit 10");
$result1 =  mysql_query("select * from players");


how would i get those 10 records to write into another table in my database called results?

eg, round1, name, id, rank, score
Link to comment
https://forums.phpfreaks.com/topic/34877-write-from-php/
Share on other sites

[code]
<?php
$result =  mysql_query("select * from players WHERE id > 1 order by level desc limit 10");
while($row = mysql_fetch_assoc($result))
{
  $var1 = $row['column1'];
  $var2 = $row['column2'];
  $var3 = $row['column3'];
  $query = "INSERT INTO results(column1, column2, column3) VALUES('$var1', '$var2', $var3')";
  $res = myslq_query($query) or die ("Insert Failed".  mysql_error()); 
}
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/34877-write-from-php/#findComment-164388
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.