There was an error. Please try again."); if(!isset($_SESSION["id"])) { unset($_POST); unset($_SESSION); header("Location: ${path}/index.php"); } include("header.inc"); $link = mysqli_connect("$dbhost", "$dbuser", "$dbpasswd", "$db"); #$db_selected = mysqli_select_db("$db", $link); #echo mysqli_connect_error($link); echo "\n\nPrint Queue\n"; ?> "; #echo "id is " . $_SESSION["id"]; $time = date("h:ia"); echo "
\n"; echo "

Your $host print queue at $time

"; echo "
"; echo "
 Job NumberSizeQueuedPages
\n"; echo "
"; # we open lpstat $username = $_SESSION["username"]; exec("$lpstat -U " . $username , $data); $i = 0; $list = count($data); #we tear each line of data apart to get arrays of jobs and users while($i<$list) { $bits = explode("\n",preg_replace("/ +/", "\n", "$data[$i]")); $sql = "select pages from queue where uid='$username' and job='$bits[0]'"; $result = @mysqli_query($link, $sql); $row = @mysqli_fetch_row($result); if($row[0] >= 1) { echo "
"; $j = 0; while($j<4): if($j!=1) echo "$bits[$j]\t"; $j++; endwhile; echo "$row[0]\n";; } $i++; if($i<$list) echo "\n"; } echo "

Select All
\n
\n"; $username = $_SESSION["username"]; $sql = "SELECT SUM(pages) FROM jobs where uid='$username' GROUP BY uid"; $result = mysqli_query($link, $sql); // Check result // This shows the actual query sent to MySQL, and the error. Useful for debugging. if (!$result) { $message = 'Invalid query: ' . mysqli_error($link) . "\n"; $message .= 'Whole query: ' . $query; die($message); } // Use result // Attempting to print $result won't allow access to information in the resource // One of the mysqli result functions must be used // See also mysqli_result(), mysqli_fetch_array(), mysqli_fetch_row(), etc. $row = mysqli_fetch_row($result); // Free the resources associated with the result set // This is done automatically at the end of the script mysqli_free_result($result); if($row[0]<1) { $row[0] = "no (i.e. you still have ${initial_quota} pages)"; } #echo "
\n"; echo "So far you have printed $row[0] free pages this semester. You know this resource is limited, right?"; ?>

Really Print Selected Jobs?

Cancel Selected Jobs

Refresh Queue

Log Out