RE: [PHP-DB] reading arrays within a field from mysql and separat ing the values

From: Date: Mon, 10 Sep 2001 21:27:58 +0000
Subject: RE: [PHP-DB] reading arrays within a field from mysql and separat ing the values
Groups: php.db 
Request: Send a blank email to php-db+get-12323@lists.php.net to get a copy of this message
Robert, Do a manual "SELECT DCD_Access FROM userdb WHERE ID = ### " and send the results. I'd like to see exactly what is in that field. The explode() should have provided an array of values rick -----Original Message----- From: Robert Trembath [mailto:robert@bacbarcodes.com] Sent: Monday, September 10, 2001 3:53 PM To: Rick Emery Subject: Re: [PHP-DB] reading arrays within a field from mysql and separating the values The same as my original message. ----- Original Message ----- From: "Rick Emery" <remery@excel.com> Newsgroups: php.db To: <php-db@lists.php.net> Sent: Monday, September 10, 2001 3:40 PM Subject: RE: [PHP-DB] reading arrays within a field from mysql and separating the values > what do you mean by it made no difference? Did you examine each element in > $myarray? What were the results? > > rick > > FYI...I tried to send directly to you and the message was bounced back > -----Original Message----- > From: Robert Trembath [mailto:robert@bacbarcodes.com] > Sent: Monday, September 10, 2001 3:30 PM > To: Rick Emery > Subject: Re: [PHP-DB] reading arrays within a field from mysql and > separating the values > > > Rick, > I tried it and it made no difference. Could you give me a more complete > example? > Thanks for the help. > Robert > ----- Original Message ----- > From: "Rick Emery" <remery@excel.com> > To: "'Robert Trembath'" <robert@bacbarcodes.com>; > <php-db@lists.php.net> > Sent: Monday, September 10, 2001 3:03 PM > Subject: RE: [PHP-DB] reading arrays within a field from mysql and > separating the values > > > > $myarray=explode(",",$DCD['DCD_Access']); > > > > Then, cycle through each $myarray element as you've done below. > > > > -----Original Message----- > > From: Robert Trembath [mailto:robert@bacbarcodes.com] > > Sent: Monday, September 10, 2001 2:55 PM > > To: php-db@lists.php.net > > Subject: [PHP-DB] 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 Database Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > > For additional commands, e-mail: php-db-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > > For additional commands, e-mail: php-db-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > >

« previous php.db (#12323) next »