Variable From PHP to Javascript -
i have code in html:
<a id="<?echo $result[id]?>" onclick="displayresult()"></a>
and want id number link without refresh page function:
<script> function displayresult() { <? connection = mysql_connect('localhost', 'root', '...'); $db = mysql_select_db('webfaturas', $connection); $sql = mysql_query("select * `artigos` id = $id"); $resultado = mysql_fetch_array($sql); ?> </script>
so can sql query id = id cames without refresh page.
what you'll want grab id of link via javascript, , post php script using ajax. jquery makes easier using straight javascript - suggest reading documentation. http://api.jquery.com/jquery.post/
Comments
Post a Comment