I'm currently working on an iOS app, which communicates with a database on a server (REST API). I've managed to send simple post queries to the server and successfully getting responses, but since a few hours I am stuck with the following php-function (it was not written by myself!). My questions:
- Is this valid php-Code? 
- Is it possible to POST both JSON-Objects and non-JSON Objects at the same time? 
- How would a valid request query look like? (I am using the Google Chrome App "Postman - REST Client" to test the queries) So what would the parameters look like if a wanted to pass tableid = 1, clientid = 1 and json = {1,2,3,4}? 
Thank you very much!
if($_POST['function'] == 'addOrder'){
    $sql = "INSERT INTO orders SET
                orderdate = NOW(),
                tableid = '".$_POST['tableid']."',
                clientid = '".$_POST['clientid']."'";
    $result = mysql_query($sql);
    $oid = mysql_insert_id();
    $orderitems = json_decode($_POST['json'],true);
    reset($orderitems);
    while(list(,$oitem) = each($orderitems)){
        $sql = "INSERT INTO orderitems SET
                        orderid = '".$oid."',
                        foodid = '".$oitem['id']."";    
        $result = mysql_query($sql);
    }
}
 
    