Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use AJAX for getting what you want.. PHP functions run before your browser loads the page because its SERVER side and any user action is user side where you can use javascript-ajax calls to add what you need..</p> <p><a href="http://api.jquery.com/jQuery.ajax/" rel="nofollow">http://api.jquery.com/jQuery.ajax/</a></p> <p>Here is the jQuery ajax .. (you need to add jquery lib so you can use it). (at you html HEAD one script tag with source the jquery lib)..</p> <p>It will make a request inside your browser when your user click on the button and it load the responde at his browser. Example..</p> <pre><code>&lt;script&gt; $(document).ready(function(){ $("#buttonID").click(function(){ $.ajax({ url: "script.php", type: "POST", data: {action : 'exportcsv'}, dataType: "text", success: function(responde){ alert(responde); /*This will show to user as message the responde*/ } }); }); }); &lt;/script&gt; </code></pre> <p>At your php you must make PAGE(in my case script.php) or part of page will responde only for that ajax call.. that means that it wont display any other information except the answer of that call.. </p> <pre><code>function exportcsv() { $File = "YourFile.txt"; $Handle = fopen($File, 'w'); $Data = "Visual BI Solutions\n"; fwrite($Handle, $Data); $Data = "ajay,praveen,musthafa,sanjay"; fwrite($Handle, $Data); fclose($Handle); } if(isset($_POST['action']) &amp;&amp; $_POST['action']=='exportcsv'){ exportcsv(); echo "SUCCESS"; exit(); /*To prevent outputing other data..*/ } </code></pre> <p>You can set it at your main php file but it must be at the first lines of your page so there are no other outputs before it. The exit() will prevent all next php code to proccess.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload