php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #12375 FAQ section on multiple select box
Submitted: 2001-07-25 15:13 UTC Modified: 2001-08-20 11:23 UTC
From: rhampton at hamptonandassociates dot net Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.0.5 OS: RH Linux 6.2
Private report: No CVE-ID: None
 [2001-07-25 15:13 UTC] rhampton at hamptonandassociates dot net
'./configure' '--with-mysql' '--with-pgsql' '--with-udb' '--with-jpeg'
                                '--with-jpeg-dir=/usr/local' '--with-xpm-dir=/usr/X11R6' '--with-xml' '--with-ftp'
                                '--with-gd' '--enable-trans-sid' '--disable-magic-quotes' '--with-dom'
                                '--with-qtdom=/usr/local/qt' '--with-zlib' '--with-mcal=../libmcal' '--with-ldap'
                                '--with-imap=../imap' '--with-gettext' '--with-db3=/usr/local/BerkeleyDB.3.2'
                                '--with-mcrypt=/usr/local/lib' '--enable-ftp' '--with-apxs=/usr/sbin/apxs'

############################
I have created an html page for a multiple select box:
If I have:
<SELECT MULTIPLE NAME="test[]">
<OPTION VALUE="10">10
<OPTION VALUE="20">20
<OPTION VALUE="30">30
<OPTION VALUE="40">40
</SELECT>

And I have a php script to look at the contents of test I get an error:

<?PHP
foreach ($test as $testing)
	{
	echo "$testing <br>\n";
	}
?>

If, however, I use the same code and make the VALUE="w","x","y","z"

I have found a workaround for using numeric values in VALUE= by encasing them in tick marks
For example:
<OPTION VALUE="'10'">

and change my php script to:
<?PHP
foreach ($test as $testing)
	{
	$testing=stripslashes($testing);
	$testing=str_replace("'","",$testing);
	echo "$testing <br>\n";
	}
?>

Summary: looks like the test[] array isn't being populated right when the value element in the option tag has a numeric value instead of character value.

Rodney Hampton
www.hamptonandassociates.net
rhampton@hamptonandassociates.net

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-25 15:30 UTC] torben@php.net
First off, it'd be quite helpful to know exactly what error you're getting. 'An error' doesn't really tell
us anything useful. :)

Secondly, I just tried this script and it worked fine. What results does it give you that you do not 
expect? (FWIW, the script you posted will give an undefined variable error when the page is first
loaded since it's trying to iterate over the $test array, which doesn't exist until you submit the form).

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML-3.2//EN">
<html>
<head>
<title></title>
</head>

<body>
  <form action="__phplist.html" method="post">
    <SELECT MULTIPLE NAME="test[]">
      <OPTION VALUE="10">10
      <OPTION VALUE="20">20
      <OPTION VALUE="30">30
      <OPTION VALUE="40">40
    </SELECT>
    <input type="submit">
  </form>

<pre>
<?php
error_reporting(E_ALL);
if (!empty($test)) {
    print_r($test);
}
?>
</pre>
</body>
</html>

 [2001-08-20 11:23 UTC] sniper@php.net
no feedback.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 22:01:26 2024 UTC