469,356 Members | 2,016 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

adding list items to a database

Not sure if this is javascript or php so i put it in both newsgroups, sorry
if it's the wrong group.

I wrote (with help) a code to put several items in a list object (select)
and I would like to add the items in this list to a database.

I know how to add a selected item to the database but how can i put al the
items tot the database. I need somekind of loop wich go's through the list.

Any suggestions
roy
Jul 23 '05 #1
1 1460
R.G. Vervoort wrote:
Not sure if this is javascript or php so i put it in both newsgroups, sorry
if it's the wrong group.

I wrote (with help) a code to put several items in a list object (select)
and I would like to add the items in this list to a database.

I know how to add a selected item to the database but how can i put al the
items tot the database. I need somekind of loop wich go's through the list.

Any suggestions
roy


Its a PHP issue... javascript will only make changes to the client (web
browser) whereas PHP is server based.

Your form has its contents written to $_POST so you can loop through its
contents with

<?
foreach($_POST as $key=>$value)
{ print("<br>$key = $value"); }
?>

You should ensure your data is clean before writing to the database - if
you don't you risk someone putting data in to the form that could give
them access to removing one or more files from your system by simply
having data input using hooks (`) or backslashes.

Download and view the php guide from php.net - I use it all the time and
its pretty good both as a function reference and it has some examples.

I suggest you buy a good book (I have Core PHP by Leon Atkinson for PHP
4 and more recently version 5 and its excellent) and also keep a close
eye on comp.lang.php as there is good help there.

regards
randelld
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by R.G. Vervoort | last post: by
26 posts views Thread by Simon Jefferies | last post: by
14 posts views Thread by Paul_Madden via DotNetMonster.com | last post: by
9 posts views Thread by Kadett | last post: by
2 posts views Thread by =?Utf-8?B?TWFobW91ZCBTaGFiYW4=?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.