Web Hosting Talk







View Full Version : missing php


ti_nhatrang
06-24-2008, 07:21 AM
Hello all,

not sure what I'm missing here... trying to see if the $leftmins is under the 70% mark of the total minutes used or not, if it is under, then print $call... not sure what i'm missing, please help:

$result = mysql_query("select * from customerdb WHERE active='1' order by active desc ,name") or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
$count++;
if ($row['OSID']=="") {
$remain[]=$row['total']-$row['totalused']."|".$row['id']; // add it up for SORT() later
$tu[]=$row['total'];
$tt[]=round($row['total'] * .70);
$ids[$row['id']]=$row['name']; // save the names in an array for ref by ID
}
}
sort($remain); // put it in order by remaining

$data = "<b>Max Concurrent Calls: </b>".$max." on ".$maxdate."<br><br>";

$data .= "<table cellpadding=0 cellspacing=3>";
$data .= "<tr><td style='padding-right:20px;'><b>Customer</b></td>";
$data .= "<td><b>Time Left</b></td></tr>";
foreach ($remain as $value) {
$info = explode("|",$value);
$leftmins = floor(($info[0])/60);
$leftsecs = str_pad(abs(($info[0])%60), 2, "0", STR_PAD_LEFT);
if ($leftmins <"$tu-tt") { $call = "hahaha"; }
$data .= "<tr><td><a href='http://".$_SERVER['HTTP_HOST']."/customers/numbers/?id=".$info[1]."'>".$ids[$info[1]]."</a></td><td>".$leftmins.":".$leftsecs."</td><td>".$call."</td></tr>";
}
$data .="</table>";

dollar
06-24-2008, 07:26 AM
Your actual if check:

$leftmins <"$tu-tt"

Seems to be a bit odd...

Did you mean something like this?
$leftmins < ($tu - $tt)

ti_nhatrang
06-24-2008, 02:56 PM
tried it, and it didn't work:

if $leftmins < ($tu-tt) { $call = "hahaha"; }

Steve_Arm
06-24-2008, 03:05 PM
I think you are missing about 5-7 lines of code.
You fill an array remain[] with values then tu[] and tt[] also.
Then you loop the remain[] array and suddenly use tu and tt which are arrays as variables.

Did you need something like:

for ($i = 0; $i < count(remain); $i++)
{
$info = explode("|", $remain[$i]);
$leftmins = floor(($info[0])/60);
$leftsecs = str_pad(abs(($info[0])%60), 2, "0", STR_PAD_LEFT);
if ($leftmins < ($tu[$i] - tt[$i])) { $call = "hahaha"; }
// OR
// if ($leftmins < "$tu[$i] - $tt[$i]")) { $call = "hahaha"; }
}

ti_nhatrang
06-25-2008, 01:26 AM
yes! Thank you so much!