[eluser]ealonw[/eluser]
Geez.... I understand the script way of going this... but i dont get the CI way...
Here's what I have in my normal script way of writing.. all this does is goes and repopulates the form based on the id... how would i write the foreach the CI way?
<?
if (isset($_GET['id']) ) {
$id = (int) $_GET['id'];
if (isset($_POST['submitted'])) {
foreach($_POST AS $key => $value) { $_POST[$key] = mysql_real_escape_string($value); }
$sql = "UPDATE `usercomment` SET `fname` = '{$_POST['fname']}' , `lname` = '{$_POST['lname']}' , `email` = '{$_POST['email']}' , `comment` = '{$_POST['comment']}' WHERE `id` = '$id' ";
mysql_query($sql) or die(mysql_error());
echo (mysql_affected_rows()) ? "Edited row.<br />" : "Nothing changed. <br />";
echo "<a href='index.php'>Back To Listing</a>";
}
$row = mysql_fetch_array ( mysql_query("SELECT * FROM `usercomment` WHERE `id` = '$id' "));
?>
<form action='' method='POST'>
<p><b>First Name:</b><br /><input type='text' name='fname' value='<?= stripslashes($row['fname']) ?>' />
<p><input type='submit' value='Edit Row' /><input type='hidden' value='1' name='submitted' />
</form>
<? } ?>