FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Query a Array Field in MySQL
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Query a Array Field in MySQL [message #179716 is a reply to message #179714] Mon, 26 November 2012 20:10 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 11/26/2012 12:04 PM, heitorfaria(at)gmail(dot)com wrote:
> Hello folks,
>
> I have the following function:
> #====================================================================
> #=======================================
> # @ Build Search Drop
> # Builds a search field drop-down list.
> #=======================================
>
> function build_search_drop($select='')
> {
>
>
> $fields = array( 'id' => 'Ticket ID', 'subject' => 'Subject', 'message' => 'Message', 'mname' => 'Submitted By', 'email' => 'Email' );
>
>
> $ift_html = "<select name='field' id='field'>";
>
> foreach( $fields as $id => $name )
> {
> if ( $select == $id )
> {
> $ift_html .= "<option value='{$id}' selected='yes'>{$name}</option>";
> }
> else
> {
> $ift_html .= "<option value='{$id}'>{$name}</option>";
> }
> }
>
> $ift_html .= "</select>";
>
> return $ift_html;
> }
>
> }
>
> ?>
> #====================================================================
>
> What in need: in $fields=array(...), I want to be able to query another (more complex) database field witch contains a MySql Array (I guess). It has this kind of information:
> #====================================================================
> a:4:{s:10:"rincidente";s:2:"ri";s:13:"codigoservico";s:5:"00000";s:3: "url";b:0;s:8:"localcpd";s:3:"bsa";}
> #====================================================================
>
> So I want to add a query that can return the value of "rincidente" or "codigoservico", for exemple. Is that possible? How I do that?
>
> Regards,
>
> Heitor Faria
>

MySQL does not have arrays. If this is what you got back from a column
in MySQL, then the database is not properly normalized (one column
contains multiple values - fails 1st normal condition).

The data is output from the php serialize() function. You will need to
unserialize() it, which will create an array for you. Then you can
access the rincidente member of the array.

And for pete's sake - get a good database design before going any
further. The current one will cause you no end of problems! (For
further information on database design, try comp.databases.mysql).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Analista Programador PHP SENIOR
Next Topic: Manually create array that matches mysql_fetch_array
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 13:38:16 GMT 2024

Total time taken to generate the page: 0.20794 seconds