-1

I am attempting to save x&y coordinates from image annotation to a sql database. I'm using a tool developed for Amazon Mechanical Turk (http://people.cs.umass.edu/~smaji/projects/mturk/).

I've set up a Linux EC2 server with javascript, mysql, php, and have the site publicly-accessible.

I believe I need to pass the javascript vars to PHP to post to a MySQL database. How do I pass javascript vars to PHP?

n__e
  • 3
  • 3
  • Fist question: YES. 2nd question: YES you should setup you database and create the table and define the fields where your data should been saved. 3rd question: There is nothing to set up with JSON or Ajax. You need to implement that in your code. The easiest is to use a library like jquery. 4th question: You need to write code. Code for posting your vars from JS to PHP. PHP-Code to connect to DB, handle your variables and put it into an Mysql-Insert-Statement. – steven Mar 18 '15 at 19:18

1 Answers1

0

Technically you can do your job like this.

  1. Store all your annotation into a single Javascript variable as JOSN values e.g,

    var annotation_values = [{x:1, y:1}, {x:2, y:1}];

  2. Either use jQuery - Javascript Library for ajax request OR submit form using (to submit your annotation_values data into database) to another page let's say image_process.php where you can collect form submitted data as $annotation_values = $_POST['annotation_values'].

  3. Now, you will have your image data in $annotation_values variable

  4. Create a MySQL table name image_processing with field name image_annotation_data to store annotation_values into it (table may have additional fields based on your application requirement)

  5. You can use mysql_query("INSERT INTO image_processing ('image_annotation_data') VALUES ($annotation_values )")

  6. When you need image_processing data, you can just fetch all image_processing data from database and re-render it on the page where you need it.

Nouman Arshad
  • 593
  • 2
  • 7