knox203 Posted June 9, 2008 Share Posted June 9, 2008 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)); ?> Link to comment https://forums.phpfreaks.com/topic/109456-solved-creating-an-array-from-values-of-a-function/ Share on other sites More sharing options...
Barand Posted June 9, 2008 Share Posted June 9, 2008 try returning the value from the function instead of echoing it Link to comment https://forums.phpfreaks.com/topic/109456-solved-creating-an-array-from-values-of-a-function/#findComment-561454 Share on other sites More sharing options...
knox203 Posted June 9, 2008 Author Share Posted June 9, 2008 Ahh, that did it! I knew I wasn't too far off =) Thanks, Barand! - Adam Link to comment https://forums.phpfreaks.com/topic/109456-solved-creating-an-array-from-values-of-a-function/#findComment-561469 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.