Multiple text box query

Reply

Join Date: Sep 2008
Posts: 2
Reputation: annasweb is an unknown quantity at this point 
Solved Threads: 0
annasweb annasweb is offline Offline
Newbie Poster

Multiple text box query

 
0
  #1
Oct 1st, 2008
Hi,

I posted this in the MySQL forum and after 3 days without any help I thought I might have it posted in the wrong forum so I am posting it here.

I am trying to query a terms database with multiple text boxes. The user has a choice of how many text boxes they want (i have this part done), they would put one term into each text box. The would have the option of checking a check box for pronunciation, date of origin, etc. These check boxes when checked would search all terms in the text boxes and return the data if available along with the definitions of each term. The definitions for each term will be listed as 1, 2, 3, etc. the output should look like this:

House (term)
1. A building for human habitation.
2. A shelter for an animal
3. A building where something is stored.

However, each of the numbered definitions should have a check box to the left and when checked and submitted will show another page with the results of the checked boxes as well as the term.

I am having difficulty getting past the select the number of word boxes. I don't seem to be able to get the query to work for the search.

Can anyone help with the type of query or script help that I would need to make.

Thanks,
ac
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,497
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 136
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: Multiple text box query

 
0
  #2
Oct 2nd, 2008
Although I don't 100% understand what you are requesting, I shall give you a script which shows how displaying the results. This however takes the knowledge of mysql querys, php and html lists.

  1. //$_POST['term1'] is first posted search variable
  2. //$_POST['term2'] is second posted search variable
  3. //$_POST['term3'] is third posted search variable
  4. $resulta=mysql_query("SELECT * FROM `tablename` WHERE `term`='".$_POST['term1']."'");
  5. echo "<ol>The term is: ".$_POST['term1']."<br>";
  6. while ($rowa=mysql_fetch_array($resulta))
  7. {
  8. echo "<li type='1'>".$rowa['definition_column_name']; //html li might be different
  9. }
  10. echo "</ol>";
  11.  
  12.  
  13. $resultb=mysql_query("SELECT * FROM `tablename` WHERE `term`='".$_POST['term2']."'");
  14. echo "<ol>The term is: ".$_POST['term2']."<br>";
  15. while ($rowb=mysql_fetch_array($resultb))
  16. {
  17. echo "<li type='1'>".$rowb['definition_column_name']; //html li might be different
  18. }
  19. echo "</ol>";
  20.  
  21.  
  22. $resultc=mysql_query("SELECT * FROM `tablename` WHERE `term`='".$_POST['term2']."'");
  23. echo "<ol>The term is: ".$_POST['term2']."<br>";
  24. while ($rowc=mysql_fetch_array($resultc))
  25. {
  26. echo "<li type='1'>".$rowc['definition_column_name']; //html li might be different
  27. }
  28. echo "</ol>";

So the above will show you the basics of displaying the result and hopefully give you enough to help answer some of the questions. Also note that the html side of the lists in the script may not be accurate and the variables will need adjusting to what they are set in your current page/mysql database.
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*`
My favourite PC. - MacGyver Fan
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC