I'm trying to implement a photo tagging system with jquery and php. I have a form with one input which is known and 6 other inputs that could vary( depends on how many people in the photo the user wants to tag. Maximum is 6 ).
The problem is the first input( Photo title) only has one value an the other possible six inputs have 4 values namely: firstname lastname x position y position
I would like to know the best way to pass all this data to php where I can make a mysql insert. At the moment I have the following code
html
<form id="uploadedphotoForm">
<textarea id="phototitle" name="title" maxlength="70" placeholder="Say something about your style."></textarea>
<input type="hidden" value="'foo','bar','10','787'" name="phototags[]" />
<input type="hidden" value="'john','doe','565','434" name="phototags[]" />
</form>
I would like to use jquery serialize to get all the data in the form so that in php I can do something like
var data = $('#uploadedphotoForm").serialize();
$.ajax({
url: 'photo.php',
type: 'POST',
data: data,
cache: false,
success: function (data) {
var json = jQuery.parseJSON(data);
if (json.status == 'uploaded') {
}
In php
$title = $_POST['title'];
Ideally I would like to get the tags in an array so I can use a mysql insert like
INSERT INTO tbl_name (firstname,lastname,xposition,yposition) VALUES("foo","bar",10,787),("john","doe","565","434");