From anonymous, 5 Months ago, written in PHP.
This paste will cross the great divide in 5 Months.
This paste is a reply to Untitled from anonymous
- go back
Embed
Viewing differences between Untitled and Re: Untitled
<?php

// Get the last ticket number entry on for a specific Service ID
$sql = "SELECT * FROM `queues` WHERE `ServiceID` = '".$serviceId."'";
"' ORDER BY QueuedID DESC LIMIT 1";
$result = $con->query($sql);
$lastTicketNum = $result['TicketNumber'];

// Increment it with one for the new entry
$newTicketNum = $lastTicketNum + 1;

// Insert the new queue data in the database table
$sql = "INSERT INTO `queues` (`QueuedID`, `ServiceID`, `CustomerID`, `TicketNumber`, `Called`, `Missed`, `CreateDateTime`)
VALUES (NULL, '".$serviceId."', '".$customerId."', '".$newTicketNum."', 0, 0, CURRENT_DATETIME)";

// Determine error or success
if ( $con->query($sql) )
    $data['status'] = 'success';
else
    $data['status'] = 'error';

// Set data array into JSON output
echo json_encode( $data );