A) Invert that $_SESSION['username']
condition to just exit or something if it's not present instead of wrapping ALL of your code in an if
B) Use a bit more meaningful variable names than ij.
C) Assuming that $row has exactly 11 fields
// replace
$index[$ij] = $row[0];
$sdate[$ij] = $row[1];
$sbranch[$ij] = $row[2];
$svendor[$ij] = $row[3];
$spo[$ij] = $row[4];
$swriter[$ij] = $row[5];
$sinv2[$ij] = $row[6];
$sinvtotal[$ij] = $row[7];
$spototal[$ij] = $row[8];
$sinvduedate[$ij] = $row[9];
$varience[$ij] = $row[10];
// with
$vars = array('index', 'sdate', 'sbranch', 'svendor', 'spo', 'swriter', 'sinv2', 'sinvtotal', 'spototal', 'sinvduedate', 'variance');
for($inc = 0; $inc < 11; $inc++) {
$$vars[$inc] = $row[$inc];
}
D) You're not ending your form tag, you're just opening another one