1

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)

2 Answers 2

6
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].

Sign up to request clarification or add additional context in comments.

2 Comments

Impressive young cularis-walker.
Don't guess, it was a good answer. Kind of magical! I will accept when the minutes allow it.
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.