query($query);
// $numresult=$result->num_rows;
//ELSE
$result=mysql_query($query);
$numresult=mysql_num_rows($result);
//ENDIF
if ($numresult!=5) die ('Unexpected number of slots: '.$numresult);
$bupdated=false;
for($i=0; $i<5; $i++)
{
//IF MYSQLI
// $row=$result->fetch_assoc();
//ELSE
$row=mysql_fetch_assoc($result);
//ENDIF
$slot=$row['Slot'];
$nKey=$row['nKey'];
$timestamp=$row['Timestamp'];
$active=$row['Active'];
$timestampUpdate=null;
$activeUpdate=null;
$timestampFvar='timestampF'.$slot;
if ($$timestampFvar!=$timestamp) $timestampUpdate=$$timestampFvar;
$activeFvar='activeF'.$slot;
if ($$activeFvar!=$active) $activeUpdate=$$activeFvar;
if (isset($timestampUpdate) || isset($activeUpdate))
{
if (!isset($dbu))
{
//IF MYSQLI
// $dbu=new mysqli('localhost', 'inters_phpUpdate', 'flask3301', 'inters_Flask');
// if (mysqli_connect_errno()) die ('Cannot update package database. Please try again later.');
//ELSE
$linku=mysql_connect('localhost', 'inters_phpUpdate', 'flask3301') or die('Could not connect: ' . mysql_error());
mysql_select_db('inters_Flask') or die('Could not select database');
//ENDIF
}
$locationUpdate=''; //Nothing
if (isset($timestampUpdate))
{ //If timestamp changes, clear location
$locationUpdate=",LastLocation=''";
}
//Shoot them both
$timestampUpdate=$$timestampFvar;
$activeUpdate=$$activeFvar;
if ($activeUpdate)
$activeUpdate='1';
else
$activeUpdate='0';
$update="update Package set Timestamp='".$timestampUpdate."', Active='".$activeUpdate."',UpdatedFrom='".$location."',UpdatedTime=CURRENT_TIMESTAMP $locationUpdate where nKey='".$nKey."' ";
//echo $update;
//IF MYSQLI
// $dbu->query($update);
//ELSE
$resultu=mysql_query($update);
if (!$resultu) die ("Could not UPDATE ($update): " . mysql_error());
//ENDIF
$bupdated=true;
}
}
$dbu=null;
//ENDIF
$result=null;
//Read time back in for formatting
if ($bupdated)
{
//Get values in order to format time
//IF MYSQLI
// $result=$db->query($query);
// $numresult=$result->num_rows;
//ELSE
$result=mysql_query($query);
$numresult=mysql_num_rows($result);
//ENDIF
if ($numresult!=5) die ('Unexpected number of slots: '.$numresult);
for($i=0; $i<5; $i++)
{
//IF MYSQLI
// $row=$result->fetch_assoc();
//ELSE
$row=mysql_fetch_assoc($result);
//ENDIF
$slot=$row['Slot'];
$timestamp=$row['Timestamp'];
$active=$row['Active'];
$slotvar='timestamp'.$slot;
$$slotvar=$timestamp;
$slotvar='active'.$slot;
$$slotvar=$active;
}
}
$result=null;
$db=null;
?>
SQL Offline - Package Receipt
Package Sender
Sender Name: | |
Sender ID: | |
Time:, from: .