php - cant fetch data thru drop down value -
i have select box in value populated database, below code
<select name="ea_name" id="ea_name"> <option value="" selected="selected">please select...</option> <?php require 'include/db_open.php'; $sql = "select ea_name ea_error order ea_name"; $mydata = mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_array($mydata)){ echo "<option value=\"$ea_name\">" . $row['ea_name'] . "</option>"; } include 'include/db_close.php'; ?> </select> now have jquery when select value changes pull data db , populate textarea
$("#ea_name").on("change", function() { $.ajax({ url: "retrieve.php", type: "post", data: { ea_name: $(this).val() }, success: function(data) { $("#results").html(data); } }); }); }); }); here query now,
<?php require 'include/db_open.php'; $ea_name = $_post['ea_name']; $sql="select * ea_error ea_name = '" . $ea_name . "'"; echo $sql; $mydata = mysql_query($sql) or die(mysql_error()); //to count if there results $numrow = mysql_num_rows($mydata) ; if($numrow == 0) { echo "no results found."; } else { echo '<fieldset><legend><strong>information</strong></legend> <table width="619" border="0" align="center"> <tr><th scope="row">error</th></tr> <tr><th scope="row">resolution</th></tr> <tr><th scope="row">contact/s</th></tr>'; while($info = mysql_fetch_array($mydata)) { echo "<form action='retrieve.php' method='post'>"; echo "<tr>"; echo "<td align='center'>" . "<textarea readonly=readonly name=error cols=75 rows=10> " . $info['error'] . "</textarea></td>"; echo "</tr>"; echo "<tr>"; echo "<td align='center'>" . "<textarea readonly=readonly name=resolution cols=75 rows=10> " . $info['resolution'] . "</textarea></td>"; echo "</tr>"; echo "<tr>"; echo "<td align='center'>" . "<textarea readonly=readonly name=contacts cols=75 rows=10> " . $info['contacts'] . "</textarea></td>"; echo "</tr>"; echo "</form>"; } } echo "</fieldset>"; include 'include/db_close.php'; ?> i've added echo $sql; can see output , here im getting: select * ea_error ea_name = ''no results found.
i tried view source , im seeing this:
notice: undefined variable: ea_name in c:\xampp\htdocs\xxx\view_transactions.php on line 75
switches
line 75 refers echo "<option value=\"$ea_name\">" . $row['ea_name'] . "</option>";
i need in understanding , fixing error...im new php coding...thanks
$ea_name not defined anywhere dont have value think looking one
echo "<option value=\"$row['ea_name']\">" . $row['ea_name'] . "</option>";
Comments
Post a Comment