Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax updating database after submit
    primarykey
    data
    text
    <p>I modified the code here (http://www.w3schools.com/PHP/php_ajax_database.asp) to update and display my database after an input box is typed and a button is clicked to submit. I have </p> <pre><code>&lt;form method="post" action="process.php" id="processer" onsubmit="showUser('me');"&gt; &lt;label for="Process"&gt;Process&lt;/label&gt;&lt;input type="text" name="process" id="process"&gt; &lt;input type="submit" value="Process"&gt; &lt;/form&gt; </code></pre> <p>My Ajax code sends a:</p> <pre><code>xmlhttp.open("GET","getuser.php?q="+str+"&amp;t=" + Math.random(),true); xmlhttp.send(); </code></pre> <p>and finally my getuser.php is</p> <pre><code>&lt;?php $q=$_GET["q"]; $con = mysql_connect('localhost', 'root', ''); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("short", $con); $sql="SELECT * FROM table WHERE creator = '$q'"; $result = mysql_query($sql); echo "&lt;table border='1'&gt; &lt;tr&gt; &lt;th&gt;id&lt;/th&gt; &lt;th&gt;data&lt;/th&gt; &lt;/tr&gt;"; while($row = mysql_fetch_array($result)) { echo "&lt;tr&gt; &lt;td&gt;" . $row['id'] . "&lt;/td&gt; &lt;td&gt;" . $row['data'] . "&lt;/td&gt; &lt;/tr&gt;"; } echo "&lt;/table&gt;"; mysql_close($con); ?&gt; </code></pre> <p>The problem is that when I click submit, sometimes 1 refreshes, sometimes 2 refresh, and others none at all. Like let's say i'm submitting the numbers 1 through 10, first time through I see 1, 2, then after inputting 3, i dont see anything, then suddenly 3, 4, and then nothing then 5 (while I just inputted 6), then 6, then 7, 8. </p> <p>Is my php display data getting cached? or how can i make the refreshing smooth and consistent?</p> <p>Thanks in advance.</p>
    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