! problem solved, new problem ....
<?php
if ( isset( $_POST['submit'] ) )
{ //if nonce check succeeds.
global $post;
$postid = $auto->ID;
$data = $_POST['doors'];
update_post_meta($postid, 'doors', $data );
}
$doors = get_post_meta($auto->ID, 'doors', true);
?>
<form method="post" action="">
<input type='text' name='doors' value='<?php echo $doors ?>' />
<input type='submit' value='save' name="submit"/>
</form>
Now it worked but my new problem is that all fields get same value...., look at img http://oi58.tinypic.com/2qtd5p4.jpg
ok your problem is that each loop is updating every item. This is because you are testing if there is a value for $_POST, up date it. You need to set a identifier so it knows which post to update.
for example, but the post id in your input field.
<input type='text' name='doors[<?php echo $auto->ID; ?>]' value='<?php echo isset($doors) ? $doors : ''; ?>' />
then you can update from this variable.
if ( isset( $_POST['doors'] ) ){
// verify nounce prob a good idea
foreach($_POST['doors'] as $item=>$key) {
$id= sanitize_text_field($item);
update_post_meta( $id, 'doors', sanitize_text_field( $key ) );
}
}
note this $_POST code appears in the loop (in-between the foreach statement and endforeach). move this to outside the loop at the top of the page to save it running everytime. Now also you can update multiple values with each submission. You will also need to check the values somehow to prevent someone changing the postmeta on any post they fancy (all they need to do it post[doors][postid] to change any doors value).