[Phpug] Help Please?????
Kae Verens
kae at webworks.ie
Fri Dec 14 08:38:22 GMT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Tony Freegrove wrote:
> Kae,
>
> Thanks for that, Someone else who is up at strange hours! I assigned the
> variables as definite values in the line following the "if($value!="")"
> statement. I've tried it with [] after them too but it just posts the
> string "array" to the DB. The initial 4 variables are not part of the array,
> the only 2 that are are $assign and $defect, as they're the only ones that
> will change. Does using a mix of definite values and arrays really mess
> with the script.
ok. taking the "i'm new to this" on board, I'll describe how to do this
generally. you can then change that general solution to apply to your
own situation.
let's say you have this form, with values generated from a DB:
<form method="post" action="save.php">
<table>
<tr>
<td><input name="name[]" value="abe" /></td>
<td><input name="phone[]" value="1234" /></td>
</tr>
<tr>
<td><input name="name[]" value="beatrice" /></td>
<td><input name="phone[]" value="5678" /></td>
</tr>
</table>
<input type="submit" />
</form>
now, in save.php, I have this snippet (opening the DB $db is left to
yourself):
// delete old values
mysql_query('delete from addressbook',$db);
// insert new values
foreach($_POST['name'] as $id=>$blah){
mysql_query('insert into addressbook (name,phone)
values ("'.mysql_real_escape_string($_POST['name'][$id]).'",
"'.mysql_real_escape_string($_POST['phone'][$id]).'")
');
}
does that help?
- --
Kae Verens
http://webworks.ie/ lead programmer
http://verens.com/ my blog
http://kfm.verens.com/ current project
- --
this is Kae's signature's signature.
yes, he really is that important.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHYkD+A9z/zIBK4hURAiAUAKDfEtDto8BFGw/zMdQDsgbNuJRG0QCgsFJ6
0EfkFoe5dakBD3UhoNxYL3k=
=L5YN
-----END PGP SIGNATURE-----
More information about the Phpug
mailing list