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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -