我试图弄清楚这一点,但代码在我的自定义函数页面上的函数内部不起作用。即使它确实运行了返回到我的报告中的值以添加到我的 $html 以供以后回显。想法???
谢谢!!
//**************** page reports.php***********//
include 'db_connect.php';
include 'functions.php';
include 'custom_functions.php';
sec_session_start();
if(login_check($mysqli) == true) {
if($sub_val ==='Jobs In This Week'){ // if week report jobs
$table = 'jobs';
$op = 'in';
$start ='';
$end = '';
mkwk();
sql_prepare($table,$op,$start,$end,$mysqli);
} // end if jobs report week
elseif($sub_val ==='Jobs In This Month'){ // if month report jobs
// functoin to make current month
mkmth();
sql_prepare($table,$op,$start,$end);
} // end if jobs report month
$html = 'add html here to build source';
echo html;
// ******** custom_functions.php ******//
function sql_prepare($table,$op,$start,$end,$mysqli,$stmt){
global $job_id,$vin,$yr,$mk,$mdl,$color,$miles_in,$miles_out,$quoted,$price,$phone,$customer,$bal,$tax,$msg,$in,$out;
if($table==='jobs'){
$stmt = $mysqli->prepare("SELECT * FROM jobs WHERE ? between ? and ? ");
$stmt->bind_param('sss', $oper,$startday,$endday);
$oper = $op;
$startday = $start;
$endday = $end;
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($job_id,$vin,$yr,$mk,$mdl,$color,$miles_in,$miles_out,$quoted,$price,$phone,$customer,$bal,$tax,$msg,$in,$out);
return $job_id;
return $vin;
return $yr;
return $mk;
return $mdl;
return $color;
echo 'sql prepare worked';
}
if($table==='expenses'){
$stmt = $mysqli->prepare("SELECT * FROM expenses WHERE ? between ? and ? ");
$stmt->bind_param('sss', $oper,$startday,$endday);
$oper = $op;
$startday = $start;
$endday = $end;
}
return $stmt;
}
// function to make current week,
function mkwk(){
// define global variable so that they be available outside the function
global $month;
global $year;
global $day;
global $dayl;
global $sday;
global $eday;
global $start;
global $end;
// do the actual work
$month = date("m");
$year = date("Y");
$day = date("d");
$dayl = date("l");
if($dayl==='Monday'){
$sday = $day;
$eday = $day+6;
}elseif($dayl==='Tuesday'){
$sday = $day-1;
$eday = $day+5;
}elseif($dayl==='Wednesday'){
$sday = $day-2;
$eday = $day+4;
}elseif($dayl==='Thursday'){
$sday = $day-3;
$eday = $day+3;
}elseif($dayl==='Friday'){
$sday = $day-4;
$eday = $day+2;
}elseif($dayl==='Saturday'){
$sday = $day-5;
$eday = $day+1;
}elseif($dayl==='Sunday'){
$sday = $day-6;
$eday = $day;
}
$start = $year.'-'.$month.'-'.$sday;
$end = $year.'-'.$month.'-'.$eday;
// return the values to the global world
return $month;
return $year;
return $day;
return $dayl;
return $sday;
return $eday;
return $start;
return $end;
}
// end function to make current week
// functoin to make current month
function mkmth(){
// define global variable so that they be available outside the function
global $month;
global $year;
global $day;
global $start;
global $end;
// do the work
$month = date("m");
$year = date("Y");
$day = date("d");
$start = $year.'-'.$month.'-01';
$end = $year.'-'.$month.'-31';
// return the values to the global world
return $month;
return $year;
return $day;
return $start;
return $end;
}
// end function for current month