2

I have a form that allows users to tag an image, choose a location from a drop-down, & upload the image. The tagging takes place by allowing multiple values, separated by commas, to be entered into a field.

This code is successfully inputting the comma delimited list to individual rows:

    $categories = $_POST['bib'];
    $categories = explode(",", $categories);
    foreach($categories as $category) {
    $category = trim($category); // Remove possible whitespace
    $sql = "INSERT INTO athletes (bib) VALUES ('%s')";
    $sql = sprintf($sql, mysql_real_escape_string($category));
    mysql_query($sql);
    }

However, it is not adding the additional content (location from drop-down list & image filename). For query purposes I need to be able to use both the 'bib' tag and the 'location' to be attached to images to allow users to search.

Before implementing the comma-separated option, this code was working to insert all of the data:

 mysql_query("INSERT INTO `athletes` VALUES ('$id', '$bib', '$race','$new_file_name')") ;

So, basically I'm trying to merge the functionality of the two.

1 Answer 1

1

You need to use MySQL's UPDATE statement to update data in an existing row.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.