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

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -