Skip to main content
deleted 12 characters in body; edited tags
Source Link
hjpotter92
  • 81.1k
  • 36
  • 148
  • 188

I would like to make a ranking.

In Table1 I collect the ID, Name, ExperiencePoint, and LvL.

Table1

In Table2 I have the LvL and the ExperiencePoint.

  • ID
  • Name
  • ExperiencePoint
  • LvL.

Table2

  • LvL
  • ExperiencePoint.

I would like to collect the data via form, into Table1. Now, everybody have to write the XP, and LvL. It

It would be better, if they post the XP, and the LvL automatically come from Table2.

I insert datas into table with this: $mysql ="INSERT INTO $table (id, name, xp, lvl) VALUES ('$id','$name','$xp','$lvl')";

$mysql ="INSERT INTO $table (id, name, xp, lvl) VALUES ('$id','$name','$xp','$lvl')"; 

And select the lvl with this: $query="select id from table2 where $lvl>=$xp LIMIT 0 , 1";

$query="select id from table2 where $lvl>=$xp LIMIT 0 , 1"; 

But how can I join the selection, and put it in the insert?

I would like to make a ranking.

In Table1 I collect the ID, Name, ExperiencePoint, and LvL.

In Table2 I have the LvL and the ExperiencePoint.

I would like to collect the data via form, into Table1. Now, everybody have to write the XP, and LvL. It would be better, if they post the XP, and the LvL automatically come from Table2.

I insert datas into table with this: $mysql ="INSERT INTO $table (id, name, xp, lvl) VALUES ('$id','$name','$xp','$lvl')";

And select the lvl with this: $query="select id from table2 where $lvl>=$xp LIMIT 0 , 1";

But how can I join the selection, and put it in the insert?

I would like to make a ranking.

Table1

  • ID
  • Name
  • ExperiencePoint
  • LvL.

Table2

  • LvL
  • ExperiencePoint.

I would like to collect the data via form, into Table1. Now, everybody have to write the XP, and LvL.

It would be better, if they post the XP, and the LvL automatically come from Table2.

I insert datas into table with this:

$mysql ="INSERT INTO $table (id, name, xp, lvl) VALUES ('$id','$name','$xp','$lvl')"; 

And select the lvl with this:

$query="select id from table2 where $lvl>=$xp LIMIT 0 , 1"; 

But how can I join the selection, and put it in the insert?

edited tags
Link
John Woo
  • 264.5k
  • 70
  • 509
  • 500
Source Link

how to insert data from table1 into table 2 in php

I would like to make a ranking.

In Table1 I collect the ID, Name, ExperiencePoint, and LvL.

In Table2 I have the LvL and the ExperiencePoint.

I would like to collect the data via form, into Table1. Now, everybody have to write the XP, and LvL. It would be better, if they post the XP, and the LvL automatically come from Table2.

I insert datas into table with this: $mysql ="INSERT INTO $table (id, name, xp, lvl) VALUES ('$id','$name','$xp','$lvl')";

And select the lvl with this: $query="select id from table2 where $lvl>=$xp LIMIT 0 , 1";

But how can I join the selection, and put it in the insert?