kaniniman Posted August 28, 2006 Share Posted August 28, 2006 I am trying to use dynamic inputs from a form to query mysql database. The table looks like below:[table][tr][td]id[/td][td]question[/td][td]answer[/td][/tr][tr][td]1[/td][td]3[/td][td]2[/td][/tr][tr][td]2[/td][td]4[/td][td]4[/td][/tr][tr][td]5[/td][td]3[/td][td]2[/td][/tr][tr][td]5[/td][td]4[/td][td]4[/td][/tr][tr][td]5[/td][td]5[/td][td]5[/td][/tr][/table]The above table is the result of inputs from the form. All I am trying to do is to create php code to go through the table and grab the "id" where (question=3 AND answer=2) and (question=4 AND answer=4) and (question=5 AND answer=5) for all possible "id" for the condition specified. Please help! Quote Link to comment Share on other sites More sharing options...
.josh Posted August 28, 2006 Share Posted August 28, 2006 [code]<?php $q = 3; $a = 2; $sql = "select id from tablename where question = '$q' and answer = '$a'"; $result = mysql_query($sql) or die (mysql_error()); while ($list = mysql_fetch_array($result)) { echo "id is {$list['id']} <br>"; }?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.