function addUserDB($conn, $user) { $QueueId = $user->getQueueId(); $Position = getLastInLine($conn, $QueueId); $Tel = $user->getTel(); $Position++; try { if (empty($Tel)) { $tsql = "INSERT INTO dbo.Users (queue_id, position)\n OUTPUT INSERTED.position VALUES ('{$QueueId}','{$Position}')"; } else { $tsql = "INSERT INTO dbo.Users (queue_id, position, telephone)\n OUTPUT INSERTED.position VALUES ('{$QueueId}','{$Position}', '{$Tel}')"; } //Insert query $conn = OpenConnection(); $insertReview = sqlsrv_query($conn, $tsql); if ($insertReview == FALSE) { die(print_r(sqlsrv_errors(), true)); } while ($row = sqlsrv_fetch_array($insertReview, SQLSRV_FETCH_ASSOC)) { $new_position = $row['position']; } sqlsrv_free_stmt($insertReview); sqlsrv_close($conn); } catch (Exception $e) { echo "Add User Error!"; } if (empty($new_position)) { return null; } else { return $new_position; } }
echo '<h1 class="cover-heading"> ' . $_SESSION['position'] . '</h1>'; echo '<h3 > In Queue "' . $_SESSION['curr_queue'] . '"</h3>'; echo '</div>'; } } if (isset($_GET['id']) || isset($_SESSION['queue_id'])) { if (isset($_GET['id'])) { $pgqid = $_GET['id']; } else { $pgqid = $_SESSION['queue_id']; } $queue_sel = getQueue($conn, intval($pgqid)); echo '<h1 class="que-heading">"' . $queue_sel->getName() . '"</h1>'; $firstInLine = getfirstInLine($conn, $pgqid); if (!empty($firstInLine)) { $lastInLine = getLastInLine($conn, $pgqid); $length = intval($lastInLine) - intval($firstInLine); for ($i = 0; $i < $length; $i++) { echo '<i class="que-circle"></i>'; } if ($length > 1) { echo '<h2>There are ' . $length . ' people ahead of you</h2>'; } elseif ($length == 1) { echo '<h2>There is ' . $length . ' person ahead of you</h2>'; } } else { echo '<h1 class="cover-heading">Queue is Empty!!</h1>'; } } ?> </div>