I am using Php/MySql and I am trying to display a table and have one of the
fields (answer) editable. What I would like is to have the user edit the
field and then click update. The result-display the table along with the
updated field. What am I doing wrong? He is my code:


include "./common_db.inc"; //sets up databse stuff






if ($id){

$query = "UPDATE questions SET answer = '$a' Where q_id = '$id'";

$result = mysql_query($query);

if (!$result) error_message(sql_error());


$query = "SELECT * FROM questions";

$result = mysql_query($query);

if (!result) error_message (sql_error());


<table width=75% border=1>

<?php while($query_data = mysql_fetch_array($result)) { ?>

<form name="update" method="post" action="<?php echo $PHP_SELF?>">


<? $id = $query_data ["q_id"];

$q = $query_data ["question"];

$a = $query_data ["answer"]; ?>

<TD WIDTH=5% ALIGN=CENTER> <?php echo"$id"; ?> </TD>

<TD WIDTH=70% ALIGN=CENTER> <?php echo"$q"; ?> </TD>

<TD WIDTH=15% ALIGN=CENTER> <input type="text" name="textfield" value="<?php
echo"$a"; ?>"> </TD>

<TD WIDTH=10% ALIGN=CENTER> <input type="submit" name="input"




<?php }?>




PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to