Note that there are some explanatory texts on larger screens.

plurals
  1. POOn/off button slide proto.io not working with Ajax PHP and MySQL
    primarykey
    data
    text
    <p>I create on/off button with <a href="http://proto.io/freebies/onoff/" rel="nofollow">http://proto.io/freebies/onoff/</a>. This button have slide animation when button click. I have some code and combine with on/off button proto.io. But, when i combine with PHP, MySQL and Ajax the button slide not working.? How to i can fix that ? </p> <p>This my code : <strong>Index.php</strong></p> <pre><code>&lt;?php $query=mysql_connect("localhost","learn","learnpass"); mysql_select_db("study",$query); include("connection1.php"); $result = mysql_query("SELECT * FROM mytable ORDER BY id"); ?&gt; &lt;script type="text/javascript"src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"&gt; &lt;/script&gt; &lt;div&gt; &lt;table id="datatables" class="display"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;ID&lt;/th&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Text&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;?php while ($row = mysql_fetch_array($result)) { ?&gt; &lt;tr&gt; &lt;td&gt;&lt;?php echo $row["id"]; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row["name"]; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row["text"]; ?&gt;&lt;/td&gt; &lt;td&gt; &lt;div class="onoffswitch"&gt; &lt;input type="hidden" value="&lt;?php echo $row["id"]; ?&gt;" /&gt; &lt;input type="checkbox" class="onoffswitch-checkbox" &lt;?php if($row['text']=="off") { echo "checked"; } ?&gt;&gt; &lt;label class="onoffswitch-label" for="myonoffswitch&lt;?php echo $row["id"]; ?&gt;"&gt; &lt;div class="onoffswitch-inner"&gt;&lt;/div&gt; &lt;div class="onoffswitch-switch"&gt;&lt;/div&gt; &lt;/label&gt; &lt;/div&gt; &lt;div id="display"&gt; &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;?php } ?&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ $('.onoffswitch').click(function(){ var hiddenValueID = $(this).children(':hidden').val(); if ($(this).children(':checked').length == 0) { var valueData = 'on'; } else { var valueData = 'off'; } $.ajax({ type: "POST", url: "ajax.php", data: {value: valueData, id: hiddenValueID} , done: function(html){ $("#display").html(html).show(); } }); }); }); &lt;/script&gt; &lt;/div&gt; </code></pre> <p>And this <strong>ajax.php</strong></p> <pre><code>&lt;?php $query=mysql_connect("localhost","learn","learnpass"); mysql_select_db("testdb",$query); if(isset($_POST['value'])) { $value=$_POST['value']; $id=$_POST['id']; mysql_query("update mytable set text='$value' where id=$id"); echo "You have Chosen the button status as:" .$value; } ?&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.
 

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