This is the code. It is part of a while loop which outputs all the rows of a database. It is for an online newsletter. There are two types of story and headline. I want the user to be able to edit stories and their associated headlines by pressing on EDIT STORY which reveals editable text via the javascript function.
PHP Code:
$submit = $_POST['form'];
if (isset($submit)) {
$result = mysql_query("UPDATE newsletter SET atitle='{$_POST['atitle']}', astory='{$_POST['astory']}', btitle='{$_POST['btitle']}', bstoy='{$_POST['bstory']}' WHERE id='{$_POST['id']}'");
}
echo '<FORM ACTION="" enctype="multipart/form-data" METHOD="POST" name="form">
<input type=hidden name="id" VALUE="' . $row['id'] . '"><tr><td width="50%"><textarea rows="1" cols="60" name="atitle">' . nl2br(stripslashes($row['atitle'])) . '</textarea><br /><textarea rows="20" cols="60" name="astory">' . nl2br(stripslashes($row['astory'])) . '</textarea></td><td with="50%"><textarea rows="1" cols="60" name="btitle">' . nl2br(stripslashes($row['btitle'])) . '</textarea><br /><textarea rows="20" cols="60" name="bstory">' . nl2br(stripslashes($row['bstory'])) . '</textarea></td></tr><tr><td colspan="2"><input type="submit" value="Save changes" name="form"></form></table></div></td></tr><tr><td colspan="2" class="style2" ><div align="right"><div align="right"><a href="javascript:;" onClick="document.getElementById(\'' . $row['id'] . '\').style.display=\'block\';">[EDIT STORY]</a></div></td></tr>';
}
?>