adding list items to a database

R

R.G. Vervoort

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
 
R

Reply Via Newsgroup

R.G. Vervoort said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top