php - HTML input value change -
i have php update page in showing text field containing value database. this, , working,
<input type="text" name="title" id="title" class="text_box" value="<?php echo $row['title']?>"/> now need put updated value in database! have used code this, it's not updating:
$title=$_post['title']; $v_id = $_get['v_id']; $sql = mysql_query("update vehicles set title = '$title' v_id = '$v_id'"); in detail... input field there. it's showing value contained in $title (retrieved database) , value edited , updated.
from side code working without showing error, value give $title giving same 1 without change.
is there other way show value in input field without putting in "value" tag? 2 things wants happen in single input field!
you'll need post form html well.
unless form looks following, code won't work
<form method='post' action='page.php?v_id=1'>    <input type="text" name="title" id="title" class="text_box" value="<?php echo $row['title']?>"/> </form> this because you're using $_get id field , $_post value field
edit edit has muddied water bit more. i'm going assume want show title , let user update title
<?php    if ($_post) {         $title = mysql_escape_string($_post['title']);         $id    = intval($_get['v_id']);         $sql   = "update vehicles set title = '$title' v_id = '$id'";         mysql_query($sql) or trigger_error(mysql_error()." ".$sql);    }     if (isset($_get['v_id'])) {        $id      = intval($_get['v_id']);        $sql     = 'select title vehicles v_id = ' . $id;        $rs      = mysql_query($sql) or trigger_error(mysql_error()." ".$sql);        $row     = mysql_fetch_assoc($rs);        $title   = htmlspecialchars($row['title']);    } ?>  <form method='post' action='?v_id=<?php echo $id?>'>    <input type="text" name="title" id="title" class="text_box" value="<?php echo $title ?>"/>    <input type='submit' value='update'> </form> this should work you. haven't error tested obviously, idea sound. should add other input screening feel necessary.
Comments
Post a Comment