Jump to content

[SOLVED] Creating an array from values of a function


knox203

Recommended Posts

Hey all, I have a simple function I made with some conditional statements, I'm trying to call this function into an array during a do-while loop. When I print the array, I get the amount of keys that should be in it, but no values. Can anyone point out what I might be doing wrong?? Thanks!

<?php
         function driver_restriction($jobcount, $basecount, $no)
{
if ( !$no ) {
	if ( $jobcount >= '10' || $basecount >= '120' ) {
		$grandtotal = "1";
		}
else {
	$grandtotal = "2";
	}
}
if ( $no ) {
	$grandtotal = "2";
	}
echo $grandtotal;
} 
?>

 

Code for the do-while:

<?php
$count = "	SELECT	date, count(date) as job_count, sum(base) as base_count
			FROM	$databasename.$databasetable
			WHERE	driver = '$username' AND left(dts, 15) = '$dts_select' AND pay_period = '".$_POST['pay_period']."'
			GROUP BY	date";
$count_query = mysql_query($count) or die (mysql_error());
         $count_result = mysql_fetch_assoc($count_query);
$count_array = array();
do {
	$daily_job_count = $count_result['job_count'];
	$daily_base_count = $count_result['base_count'];
	$count_array[] = driver_restriction("$daily_job_count", "$daily_base_count", "$no_result"); } while ($count_result = mysql_fetch_assoc($count_query)); 
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.