Current location: Hot Scripts Forums » Programming Languages » PHP » Putting multiple values from list into one field


Putting multiple values from list into one field

Reply
  #1 (permalink)  
Old 02-03-04, 04:39 PM
rush989 rush989 is offline
Newbie Coder
 
Join Date: Aug 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Putting multiple values from list into one field

Hi there,

I'm kinda stumped on how to do this. I have a list box where I can select multiple things by holding down control (example at: http://www.mypartz.com/example.html). I was wondering how I could get the selected items into a variable so I can put them into one field in my database. The values can be in the variable separated by spaces or commas. This is so I can use my friend's search script on the variable to display certain rows.

When I try it out by using
$query = "INSERT INTO reviews (keywords) VALUES ('$keywords')";
it only puts in the last value selected.

I'm a beginner in php so I don't really know much but as long as it's in a variable I will know what to do. Thanks everyone!
Reply With Quote
  #2 (permalink)  
Old 02-04-04, 04:47 AM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
Use this on your form....
<SELECT name="select_name[]">

Then in your script to insert, use this....
$abc=$_POST['select_name];
for ($i=0; $i<count($abc); $i++){
$field_name = $field_name." ".$abc[$i];
}
$query = "INSERT INTO table_name VALUES ('$field_name')";
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
formmail problem gscraper Perl 12 08-27-04 03:06 AM
Formmail Script Fix - Cant display multiple list selections.. zamen PHP 3 05-02-04 09:59 AM
multiple values in one field smallbeer PHP 6 12-17-03 04:45 AM
MySQL table problem perleo PHP 9 12-16-03 01:16 PM
Form field values don't show in my browser cstallins PHP 6 10-19-03 11:12 AM


All times are GMT -5. The time now is 08:15 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.