Get the names of IDs from different table
Posted
by
user896692
on Stack Overflow
See other posts from Stack Overflow
or by user896692
Published on 2012-10-10T15:24:26Z
Indexed on
2012/10/10
15:37 UTC
Read the original article
Hit count: 112
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?
© Stack Overflow or respective owner