Welcome to WebmasterWorld Guest from 54.145.167.92

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

call php from web page

change from calling

   
6:08 pm on Nov 12, 2011 (gmt 0)



I have a php page that reads the $_get variable and connects to database to run query and return data. If I want to move my php code to the top of the calling page instead whats the best way to pass the variable to the code? In other words instead of calling getdata.php from index.php I just want to have the php code before html and have it run from a link or button.
2:38 pm on Nov 14, 2011 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



to run php code from a button you would have to submit to the server again, not sure if that is what you mean.

Your php code can be anywhere in the actual script, the top is always a good place since you probably want to use the data you get inside the page somewhere.

I don't exactly understand the series of events you want to have.
4:55 pm on Nov 14, 2011 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Some minified code would be helpful.

Can you include the second script in the first one?

<?php
// Script that connects with DB
// Pass a variable for "full page" if not an include
if (isset($_GET['full_page'])) {
// output header
}
//output database stuff
if (isset($_GET['full_page'])) {
// output footer
}
?>

Then in index.php,

include('db-get-script.php');
9:47 pm on Nov 15, 2011 (gmt 0)



I'm struggling through with ajax solution. Been a long time since I did any php so it like leaning it all over.