data.php
is main file and if the search terms not within the database then it should call getdata.php
to grab data. so how do I call this in this script.
$db = mysql_connect($db_host, $db_username, $db_password) or die("Could not connect.");
mysql_select_db($databse_name,$db)or die(mysql_error());
$row = mysql_fetch_assoc($result);
if($row > 0){
//show the result
}else{
//call getdata.php
}
but how I call getdata.php
without using header()
?
...}else{
include( 'getdata.php' )
}
require('getdata.php'); comes to mind
You can do either as Carlos said, or you can use
require('getdata.php');
It all depends on if you want the application to produce a warning if getdata.php does not exist or if you want the application to produce a fatal error (require will produce the fatal error).
It might also be good practice to use require_once() instead to ensure the file is not included more than once at any point.
Hope this helps.
From here
// Something like this
$execute = /path/to/php/script.php
;
// If you needed the output echo $execute;
You can also refer to PHP Execution Operators
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.