如何在javascript中使用sql? [英] how to use sql in javascript?
本文介绍了如何在javascript中使用sql?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<? php
包括' < span class =code-string> connections.php'; // db
?>
< 按钮 类型 = 按钮 class = btn btn-primary btn-sm onclick = myFunction() id = reqst > 提交< /按钮 >
< script >
function myFunction( ){
// include connections.php file
// 需要执行诸如select,insert等的SQL操作。
}
< span class =code-keyword>< / script >
<? php
}
?>
提交后需要在javascript中执行sql操作。反正有没有这样做?请任何人帮助我
解决方案
https:// www .google.com / search?q = sql + php [ ^ ]。
您的客户端脚本无法直接访问数据库。最接近的是通过Ajax调用,但它仍然必须通过像php这样的服务器辅助脚本,它依次处理数据库操作。
Ajax示例[ ^ ]
<?php
include 'connections.php';//db
?>
<button type="button" class="btn btn-primary btn-sm" onclick="myFunction()" id="reqst">Submit</button>
<script>
function myFunction(){
// include connections.php file
// need to perform sql operations like select,insert etc.
}
</script>
<?php
}
?>
after submit need to perform sql operations in javascript. Is there anyway to do this? please anyone help me
解决方案
https://www.google.com/search?q=sql+php[^].
You client-side script has no access to the database directly. The closest is via Ajax call, but it still has to go through a server-aide script like php which in turns handles the database operation.
Ajax example[^]
这篇关于如何在javascript中使用sql?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文