logo

This is an old version of this answer!

Return to the current answer
Put this in your loop


<form action="" method="post">
<input type="text" name="Name" value="username1">
<input type="hidden" name="toPost" value="<?echo $post->ID; ?>">
<input type="submit" value="Submit" name="submit">
</form>


and this somewhere out of the loop:

 

<?php

if(isset($_POST['submit'])) //If submit is hit
{


$name = ','.mysql_real_escape_string($_POST['Name']); // fetch user input from the form. You could use user_id or username
$toPost = $_POST['toPost']; // our post_id to insert username


$result=mysql_query("UPDATE wp_postmeta SET meta_value=concat(meta_value, '$name') WHERE post_id=$toPost AND meta_key='Name'");
//SQL query: add to field "Name" new username

// uncomment for debug
//print mysql_affected_rows();
// print mysql_error();


if(!$result) die('Error: '.mysql_error());
else echo 'Inserted row with id='.mysql_insert_id();
}

?>



This will add the value of form to post you chose.
Finally you could insert user_id or his username and delete the textarea

Mykyta Savchenko | 08/12/10 at 10:26am

This is an old version of this answer!

Return to the current answer