xcislav Posted April 14, 2014 Share Posted April 14, 2014 The idea is simple. A key you press (a letter) appears in updated page:keyj.php: <input id='k'></input> <script type="text/javascript"> document.getElementById('k').onkeypress=function() { <?php $db=new PDO('mysql:host=localhost;dbname=test;charset=utf8','$us','$ps'); $db->exec("UPDATE TXT SET texts=k.value"); $rl=$db->query("SELECT texts FROM TXT"); print_r($rl->fetchColumn()); ?> } </script> The intention is to have text on the screen via print_r. I successfully used it in another php to exchange information with MySQL and users screen (worked).Here - the more you type and the more k.value is the more text will be on screen (just from server).Unfortunately something went wrong. Link to comment https://forums.phpfreaks.com/topic/287754-save-to-mysql-and-show-text-while-typing-onkeypress/ Share on other sites More sharing options...
trq Posted April 14, 2014 Share Posted April 14, 2014 PHP executes on the server, long before any javascript is sent to the client to be executed. Link to comment https://forums.phpfreaks.com/topic/287754-save-to-mysql-and-show-text-while-typing-onkeypress/#findComment-1476070 Share on other sites More sharing options...
xcislav Posted April 15, 2014 Author Share Posted April 15, 2014 PHP executes on the server, long before any javascript is sent to the client to be executed. I'm very sorry, I hoped... it's ok. Link to comment https://forums.phpfreaks.com/topic/287754-save-to-mysql-and-show-text-while-typing-onkeypress/#findComment-1476186 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.