Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

This is probabaly a basic request im sure alot of people have implemented on JTABle (jtable.org). I basically want to do a check when adding a new record in the list action file and if the record already exisits to actually spit out a message back to the user that the record already exisists. At the moment I find it sometimes says its inserted but i know it already exisists or I just get an error message which is meaningless to the end user.

I am coding in PHP not ASP

This is my list action , just a snapshot of the Creating a new record :

//Creating a new record (createAction)

    $qStr = "INSERT INTO teg_priority(CIDN,CustomerName,Service_Manager,NGM,Tag,CBS) VALUES(" . $_POST["CIDN"] . ", '" . $_POST["CustomerName"] . "' , '" . $_POST["Service_Manager"]."','" . $_POST["NGM"]."','" . $_POST["Tag"]."','" . $_POST["CBS"]."');";


    //Insert record into database
    $result = mysql_query($qStr);


    //Get last inserted record (to return to jTable)
    $result = mysql_query("SELECT CIDN,CustomerName,Service_Manager,NGM,Tag,CBS FROM teg_priority WHERE CIDN = " . $_POST["CIDN"] . ";");

    $row = mysql_fetch_array($result);

    //Return result to jTable
    $jTableResult = array();
    $jTableResult['Result'] = "OK";
    $jTableResult['Record'] = $row;
    print json_encode($jTableResult);

}

share

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.