Get the names of IDs from different table
- by user896692
I have an array with a lot of data from a database. In the array, there are two fields called teameinsid and teamzweiid. The query is a very simple one :
$spiel = mysql_query("select teameinsid, teamzweiid from begegnung", $connection) or die("Keine passende Begegnung");
What I need is to search in the database for the names of these IDs. The names are in a different table.
What I have now is the following:
while($tmp = mysql_fetch_array($spiel)){
$teins = $tmp['teameinsid'];
$tzwei = $tmp['teamzweiid'];
}
So I know the two IDs, but I don't know where to save the names. If I try:
$name = mysql_query("select name from team where teameinsid = $teins", $con)
it gets overwritten every time. How can I manage this?