Reputation: 81
My first query should return a single result.
$query="select idtechnic from technic where idname='$technic' and setname='$set' and number='$number'";
I would like to use the result of the above query in a second query:
$result=mysql_query($query);
$row1=mysql_fetch_assoc($result)
$query1="select idtechnic, move from moves where idtechnic='$row1[0]' order by idmoves";
I also tried mysql_fetch_array($query)
and mysql_result($query, 1)
Upvotes: 1
Views: 79
Reputation: 26961
mysql_fetch_assoc
fetches an associative array (aka hash or map). So, your idtechnic
value reside in $row1['idtechnic']
. But you'd better combine the queries like @cularis suggests, as it will result in faster and more readable code.
Upvotes: 1
Reputation: 43309
SELECT moves.idtechnic, moves.move
FROM moves
INNER JOIN technic
ON technic.idtechnic=moves.idtechnic
WHERE technic.idname='$technic'
AND technic.setname='$set'
AND technic.number='$number'
ORDER BY moves.idmoves
Combine the two queries with a INNER JOIN [MySQL Docs].
Upvotes: 6