Jump to content

NEED HELP inputing array into mysql!


mrsmile25

Recommended Posts

I set up mySQL cell named \"Type\" and as a set(\'All\', \'Conventional\', \'Course\')

 

Now, my forms are set-up as:

 

<input type=\"hidden\" name=\"Type\" value=\"$set$\" />

<select name=\"Type[]\" size=3 multiple=\"multiple\">

<option value=\"All\">All</option>

<option value=\"Conventional\">Conventional</option>

<option value=\"Course\">Course</option>

</select>

 

And it only allows me to input 1 option. I\'m lost. Any ideas. Thank you very much.

Link to comment
Share on other sites

For different MySQL data types, use inputs phpMyAdmin is using, this can help: (ref: http://www.phpmyadmin.net).

 

For example:

varchar, int, char, float: use input of type text (or password).

enum: use select or radio buttons (one choice only)

set: use select with attribute multiple="multiple" and a size="x" where x is min(number of items, 7) (note: 7 is a magic number for interfaces displaying item listings) or checkboxes (multiple choices)

text: use textarea

For your situation, since you only have 3 choices, I would use checkboxes. They all have the same name (name=\"Type[]\") only their value are different. To insert their values into MySQL, simply use implode() method:

// let\'s say values are in $_POST[\'Type\']:

$sql = "INSERT INTO table SET Type = \'".implode(",", $_POST[\'Type\'])."\'";

JP.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.