RE: [PHP-WIN] reading arrays within a field from mysql and separa ting the values
| From: | Asendorf, John | Date: | Mon, 10 Sep 2001 19:54:34 +0000 |
| Subject: | RE: [PHP-WIN] reading arrays within a field from mysql and separa ting the values | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-9303@lists.php.net to get a copy of this message | ||
I have no idea if this will work:
$DCD = mysql_fetch_array ( $result4 );
$DCD = array ( $DCD );
I'm just wondering if you need to force PHP to understand that DCD is an
array?
or maybe:
settype ( $DCD , "array" );
$DCD = mysql_fetch_array ( $result4 );
---------------------
John Asendorf - jasendorf@lcounty.com
Web Applications Developer
http://www.lcounty.com - NEW FEATURES ADDED DAILY!
Licking County, Ohio, USA
740-349-3631
Aliquando et insanire iucundum est
> -----Original Message-----
> From: Robert Trembath [mailto:robert@bacbarcodes.com]
> Sent: Monday, September 10, 2001 3:42 PM
> To: php-windows@lists.php.net
> Subject: [PHP-WIN] reading arrays within a field from mysql and
> separating the values
>
>
> Hello everyone,
>
> Ran into a problem trying to get this to work. I have
> multiple names in a
> mysql field (DCD_Access) that contains "name1, name2, name3,
> name4" and I
> want read this information as an array so I can use these
> values to populate
> a pull-down list using a while or foreach loop. Below is the
> code I used,
> but I get the values as a single entry no matter what I try.
> This query
> brings a single result row "name1, name2, name3, name4".
> Here's the code:
>
> $result4 = mysql_query( "SELECT DCD_Access FROM userdb WHERE ID =
> '$user_ID'");
> $DCD = mysql_fetch_array ( $result4 );
>
> print " <td width='6%' valign=top>\n
> <div align='center'>\n
> <select name='LCompare'>\n
> <option value='none'>None</option>\n
> <option value='within'>Within Gel</option>\n";
> foreach ( $DCD as $val )
> {
> print "<option value='$val'>$val</option>\n";
> }
> print " </select></div>\n
> </td>\n";
>
> This returns HTML like:
>
> <td width='6%' valign=top>
> <div align='center'>
> <select name='LCompare'>
> <option value='none'>None</option>
> <option value='within'>Within Gel</option>
> <option value='name1, name2, name3, name4'>name1,
> name2, name3,
> name4</option>
> <option value='name1, name2, name3, name4'>name1,
> name2, name3,
> name4</option>
> <option value='name1, name2, name3, name4'>name1,
> name2, name3,
> name4</option>
> <option value='name1, name2, name3, name4'>name1,
> name2, name3,
> name4</option>
> </select>
> </div> </td>
>
> What I need is to get:
>
> <td width='6%' valign=top>
> <div align='center'>
> <select name='LCompare'>
> <option value='none'>None</option>
> <option value='within'>Within Gel</option>
> <option value='name1'>name1</option>
> <option value='name2'>name2</option>
> <option value='name3'>name3</option>
> <option value='name4'>name4</option>
> </select>
> </div> </td>
>
> Anyone know how to fix this?
> Robert
>
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
> For additional commands, e-mail: php-windows-help@lists.php.net
> To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
>