Button to open Table from array?

I’m kind of new to PHP and have spent a while trying to figure out with the form button won’t open the function in my php code?
It’s probably something simple, but I just can’t figure it out! It’s driving me insane.

Here’s the php:

<?php> $myFileName = "courses.txt"; // Name of file courses $pointer = fopen("courses.txt", "r"); // open courses.txt file function allFunction(){ //TABLE print ''; while (!feof($pointer)) { print ''; $thisLine = fgets($pointer, 4096); $courseArray = explode("\t", $thisLine); foreach ($courseArray as $item) { echo '' ; } print ''; } print '
' . $item . '
'; } ?>

and here’s the form button in html:

If somebody could help that would be awesome!!

You can not call function written in PHP in the onclick event. Use javascript for this. Code written in PHP is executing on the server side, so by the time when you see results in your browser, php’s job done - HTML page generated.

For your task it is probably best to use PHP and Ajax. Make your PHP code in a separate file, and add javascript function that would request your php script on button click. Check jQuery ajax method, and examples on that page.

Sponsor our Newsletter | Privacy Policy | Terms of Service