Welcome Guest, Not a member yet? Register   Sign In
Having problems with creating a CRUD..
#21

[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' "));
?&gt;

&lt;form action='' method='POST'&gt;
<p><b>First Name:</b><br />&lt;input type='text' name='fname' value='&lt;?= stripslashes($row['fname']) ?&gt;' /&gt;
<p>&lt;input type='submit' value='Edit Row' /&gt;&lt;input type='hidden' value='1' name='submitted' /&gt;
&lt;/form&gt;
&lt;? } ?&gt;


Messages In This Thread
Having problems with creating a CRUD.. - by El Forum - 06-05-2008, 12:03 PM
Having problems with creating a CRUD.. - by El Forum - 06-05-2008, 12:22 PM
Having problems with creating a CRUD.. - by El Forum - 06-05-2008, 05:14 PM
Having problems with creating a CRUD.. - by El Forum - 06-06-2008, 11:26 AM
Having problems with creating a CRUD.. - by El Forum - 06-06-2008, 11:34 AM
Having problems with creating a CRUD.. - by El Forum - 06-06-2008, 11:38 AM
Having problems with creating a CRUD.. - by El Forum - 06-06-2008, 11:46 AM
Having problems with creating a CRUD.. - by El Forum - 06-06-2008, 12:01 PM
Having problems with creating a CRUD.. - by El Forum - 06-06-2008, 12:16 PM
Having problems with creating a CRUD.. - by El Forum - 06-07-2008, 01:58 AM
Having problems with creating a CRUD.. - by El Forum - 06-10-2008, 12:45 PM
Having problems with creating a CRUD.. - by El Forum - 06-10-2008, 01:01 PM
Having problems with creating a CRUD.. - by El Forum - 06-10-2008, 02:22 PM
Having problems with creating a CRUD.. - by El Forum - 06-10-2008, 02:54 PM
Having problems with creating a CRUD.. - by El Forum - 06-10-2008, 03:22 PM
Having problems with creating a CRUD.. - by El Forum - 06-10-2008, 03:47 PM
Having problems with creating a CRUD.. - by El Forum - 06-11-2008, 04:50 PM
Having problems with creating a CRUD.. - by El Forum - 06-11-2008, 05:57 PM
Having problems with creating a CRUD.. - by El Forum - 06-12-2008, 10:09 AM
Having problems with creating a CRUD.. - by El Forum - 06-12-2008, 12:33 PM
Having problems with creating a CRUD.. - by El Forum - 06-12-2008, 02:52 PM
Having problems with creating a CRUD.. - by El Forum - 06-12-2008, 08:50 PM



Theme © iAndrew 2016 - Forum software by © MyBB