Inserting multiple selections from forms

wxdqz

New Member
I am making a CD-Request database using apache/php/mysql and I have come to a snag.
I want to be able to insert multiple platforms, however all I get back is "Array"
when I try to insert the platform[]. I need this because I have some CDs that
are available for multiple operating systems. If I just name the SELECT
form field 'platform', all I get back is the first item selected. I have
searched through many manuals, newsgroups, and discussion boards and have
not found what I need. I have thought about using the SET() column type,
but what if I get cd with a new operating system, I am going to have to go
and alter the column SET to add another value. I do not want
to have to do that. (If I am wrong about that let me know). The <SELECT> on the
html page will actually be created from a "SELECT DISTINCT cd_platform FROM cd_inv"
I will also have an "Other" option where the user can select from the given
choices and if Other is selected, they can type in a new operating system.

Thanks in advance for any help!
-dg

html page:


<BODY>
<FORM NAME="myform" METHOD="post" ACTION="test2.php">
<INPUT TYPE="text" NAME="title"><BR>
<SELECT MULTIPLE NAME="platform[]">
<OPTION VALUE=http://www.phpbuilder.com/board/archive/index.php/"Sun SPARC Solaris">Sun SPARC Solaris
<OPTION VALUE="Microsoft Windows 2000">Microsoft Windows 2000
<OPTION VALUE="Redhat Linux">Redhat Linux
<OPTION VALUE="Novell Netware">Novell Netware
</SELECT>
<BR>
<INPUT TYPE="submit">
</FORM>
</BODY>


php page:

<?php
$conn = mysql_connect("localhost","cdreq","cdreq");
mysql_select_db("cd_request_test",$conn) or die("The database is not available");
mysql_query("INSERT into cd_inv (cd_title, cd_platform) values('$title', '$platform')");

$result = mysql_query("select * from cd_inv");
while ($myrow = mysql_fetch_array($result)) {
printf("<BR><BR><B>Title: </B>%s \n<BR><B>Platform: </B>%s\n",$myrow["cd_title"], $myrow["cd_platform"]);
}
mysql_close($conn);
?>


table:

mysql> desc cd_inv;
+-------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+----------------+
| cd_id | int(11) | | PRI | 0 | auto_increment |
| cd_title | varchar(80) | YES | | NULL | |
| cd_platform | varchar(40) | YES | | NULL | |
+-------------+-------------+------+-----+---------+----------------+


Output:

test1.html:

|-------------------|
|Some Software Title|
|-------------------|

|------------------------|
|(Sun SPARC Solaris) |
|Microsoft Windows 2000 |
|(Redhat Linux) |
|Novell Netware |
|------------------------|

[Submit Query]


test2.php:

Title: Some Software Title
Platform: Array
 
Back
Top