troubleshooting Question

Javascript - Fill text value from radio button select

Avatar of dolan2go
dolan2goFlag for United States of America asked on
JavaScriptMySQL ServerPHP
7 Comments1 Solution677 ViewsLast Modified:
This is a combination of 2 questions previously asked.

I want the selection of one radio button to add a mysql query to the text box below. I've gotten to the point that one query (#2), while filling the input > text > value of the php/html source, does not appear in the text box.

The further issue is how the query gets processed by php and then mysql. At this point , the 2nd query reports 1065, empty query, after inserting and submitting the code below thru the php script. The same code, returns 19 rows in phpMyAdmin.

SELECT a.email1, a.empNum, b.runTime FROM User a, NonRev_Check_in b WHERE b.runTime LIKE '%11-14%' AND a.empNum = b.empNum

Here's a shortened version of the php script.

$query_1 = "SELECT email1 FROM User WHERE empNum = 354";
$query_2 = "SELECT a.email1, a.empNum, b.runTime FROM User a, NonRev_Check_in b WHERE b.runTime LIKE '\%11-14\%' AND a.empNum = b.empNum";
$query_3 = "SELECT email1, listingPhone FROM User WHERE empNum = 354";

if ( $_POST['submit']
   $connect = mysql_connect ( $host, $db_user, $db_password );
   mysql_select_db ( $database );

   if ( isset ( $_POST['query'] ) )
      $query = mysql_real_escape_string ( $_POST['query'] );
   echo $query . "<br />";

<form name="query" action="/admin/email.php" method="post">
   <input type="radio" name="que" onclick="if(this.checked)document.getElementById('query').value='<?php print $query_1 ?>';" /> Email &nbsp;
   <input type="radio" name="que" onclick="if(this.checked)document.getElementById('query').value='<?php print $query_2 ?>';" /> Check-in &nbsp;
   <input type="radio" name="que" onclick="if(this.checked)document.getElementById('query').value='<?php print $query_3 ?>';" /> Phone &nbsp;
   <br />
   Query: &nbsp; 
   <input type="text" id="query" size="50" name="query" value="" />
   <input type="submit" name="submit" value="Submit" />

Thanks for looking.


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros