Note that there are some explanatory texts on larger screens.

plurals
  1. POajax and jquery select box post method using php and mysql
    primarykey
    data
    text
    <p>I am using ajax and jquery select box post script.</p> <p>my problem is value id . When i clik the post then database table showing only id number. But i want to post is_kategorisi . What can i do ? <strong>This is my select box:</strong></p> <pre><code> &lt;?php include('db.php'); $is_kategorisi =$_POST['id']; $query = "SELECT * FROM business_category"; $res = mysql_query($query); ?&gt; &lt;select id="parent_category" name="sirket_kategorisi" accept-charset="UTF-8" /&gt; &lt;?php echo "&lt;option value=''&gt;Şirket Kategoriniz&lt;/option&gt;"; while($row = mysql_fetch_array($res)) { echo "&lt;option value='".$row['is_kategorisi']."'&gt;".ucfirst($row['is_kategorisi'])."&lt;/option&gt;"; } ?&gt; &lt;/select&gt; </code></pre> <p><strong>and this is my php code for post:</strong></p> <pre><code>&lt;?php include("includes/connect.php"); if(isset($_POST['submit'])){ $sirket_kategorisi = $_POST['sirket_kategorisi']; $query ="INSERT INTO `users` (`sirket_kategorisi`) VALUES ('$sirket_kategorisi')"; $result = mysql_query($query) or die(mysql_error()); if($result){ echo("&lt;center&gt;&lt;h1&gt;OK!&lt;/h1&gt;&lt;/center&gt;"); } else { echo("&lt;center&gt;&lt;h1&gt;Not OK!&lt;/h1&gt;&lt;/center&gt;"); } } ?&gt; </code></pre> <p><strong>ajax code :</strong></p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $("#parent_category").change(function() { var category_id = $(this).val(); if(category_id != '') { $.ajax ({ type: "POST", url: "get_child.php", data: "category_id="+ category_id, success: function(option) { $("#child_category").html(option); } }); } else { $("#child_category").html("&lt;option value=''&gt;-- No category selected --&lt;/option&gt;"); } return false; }); }); &lt;/script&gt; </code></pre> <p><strong>get_child.php</strong></p> <pre><code>&lt;?php include('db.php'); ?&gt; &lt;?php if(isset($_POST['category_id']) &amp;&amp; $_POST['category_id'] != '') { $category_id = $_POST['category_id']; $category_id = mysql_real_escape_string($category_id); $query = "SELECT * FROM business_category_name where catg='".$category_id."'"; $res = mysql_query($query); if(mysql_num_rows($res)) { while($row = mysql_fetch_array($res)) { echo "&lt;option value='".$row['category_name']."'&gt;".ucfirst($row['category_name'])."&lt;/option&gt;"; } } } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload