php include and mysqli prepare

maverfax

New Member
Im trying to figure this out but code isnt working inside of a function on my custom functions page. even if it does run the values arent returned to my reports to add to my $html for later echoing. ideas????Thanks!!\[code\]//**************** 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 monthfunction 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\[/code\]
 
Back
Top