0

If I have a page of 50 lines and I want to run 10-20 lines again if i click on some button..

Is there any way to do this??

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by kirtan_thakkar
0

You can create a function for the 10-20 lines.
Then, on the page print a link such that it has an extra HTTP GET attribute at the end.
Like if your URL is page.php then append ?e=1
Now in your PHP script, check for value of $_GET if it is 1, 2, etc. (use switch-case if there are a lot) and call the function you created.

0

You can create a function for the 10-20 lines.
Then, on the page print a link such that it has an extra HTTP GET attribute at the end.
Like if your URL is page.php then append ?e=1
Now in your PHP script, check for value of $_GET if it is 1, 2, etc. (use switch-case if there are a lot) and call the function you created.

Sorry, but i have not understood the logic..
Can you explain..
And how to call function on click to some text or link

Edited by kirtan_thakkar: n/a

0
function code_to_be_executed() {
// This is the code to be executed on a special action
// The 10-20 lines
}

// Now the general flow:

echo '<a href=page.php?e=1>....</a>';

if(isset($_GET['e']) and $_GET['e'] == 1) {
code_to_be_executed();
exit; // exit after our special code is executed.
}

// Some first ten lines
// Then call the function to execute the 10-20 lines we had
code_to_be_executed();
0

Thanks for explaining..

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.