cainam29 Posted July 17, 2013 Share Posted July 17, 2013 I want to pull up the data that corresponds to the value of the drop down and show it to a text area within a fieldset, I want my page to just initially show the drop down then after selecting a value it will show the data in a text area without refreshing the page, here is the code: <div id="mainContent"> <table width="619" border="0" align="center"> <td align="center"><form id="form1" name="form1" method="post" action="" > <fieldset> <legend><strong>EA</strong></legend> <p> <select name="ea_name" id="ea_name"> <option value="" selected="selected">Please select...</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> </p> </fieldset> </form></td> </table> <div id="results"></div> </div> Here is the code that I've tried that will pull up data and show to a text area but all im getting is No results found. <?php require 'include/DB_Open.php'; $ea_name = $_POST['ea_name']; $sql="SELECT * FROM ea_error WHERE ea_name = '" . $ea_name . "'"; $myData = mysql_query($sql); //to count if there are any results $numrow = mysql_num_rows($myData); if($numrow == 0) { echo "No results found."; } else { echo '<fieldset><legend><strong>Information</strong></legend><p> <table width="auto" height="172" border="0"> <tr><th>Error</th></tr> <tr><th>Resolution</th></tr> <tr><th>Contact/s</th></tr>'; while($info = mysql_fetch_array($myData)) { echo "<form action='retrieve.php' method='post'>"; echo"<tr>"; echo "<td align='center'>" . $info['error'] . "<input type=hidden name=error value=" . $info['error'] . " </td>"; echo "<td align='center'>" . $info['resolution'] . "<input type=hidden name=resolution value=" . $info['resolution'] . " size='11' maxlength='11' /> </td>"; echo "<td align='center'>" . $info['contacts'] . "<input type=hidden name=contacts value=" . $info['contacts'] . "' /> </td>"; echo "</tr>"; echo "</form>"; } } echo "</fieldset>"; include 'include/DB_Close.php'; ?> Quote Link to comment Share on other sites More sharing options...
Barand Posted July 17, 2013 Share Posted July 17, 2013 Your form has no submit button so how are you sending the selected value? Quote Link to comment Share on other sites More sharing options...
cainam29 Posted July 17, 2013 Author Share Posted July 17, 2013 through a jquery... Quote Link to comment Share on other sites More sharing options...
fastsol Posted July 17, 2013 Share Posted July 17, 2013 Just do some basic diagnostics then, first you need to sanitize the value of your post. According to your select menu it's an integer but I assume that is just an example, so you need to use mysql_real_escape_string() and then add mysql_error() after the query to see why the query is failing. $ea_name = mysql_real_escape_string($_POST['ea_name']); $myData = mysql_query($sql); echo mysql_error(); 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.