Subject:*
<
Name/Email:*
<
Message Icon:*
<
Select*
<
Message:*
<



Click the Preview to see the content in action.
Options:*
<
Confirmation Code*
<
0 + 3 = ?  
Input the result from the expression
Maximum attempts you can try: 10
*
<
     
query("SELECT * FROM ".$xoopsDB->prefix("your_country_table")."; while($myrow = $xoopsDB->fetchArray($query) ) { $countries[$q]['id'] = $myrow['CountryID']; $countries[$q]['name'] = $myrow['CountryName']; $q++; } foreach (array_keys($seasons) as $j) { $country['id'] = $countries[$j]['id']; $country['name'] = $countries[$j]['name']; echo"$country[name]\n"; } echo""; [/code] Of course you have to change the table name and the field names according to your XOOPS DB Table. In the first part the array is filled with the query data, in the second part the array data is filled into the select box. There are many ways to fill the array depending on your application, so this is just one possible example. Marco[/quote]" />

Re: Drop down menu with unserlize function ?
by mawi27 on 2008/5/19 14:37:23

Hi slyss,
the unserialize() function explained by trabis is much better than parsing the string as i have worked out in your other posts! You should change your code so that you only use this function.

best regards,
Marco
Re: Drop down menu with unserlize function ?
by slyss on 2008/5/19 6:31:06

many thanks ;)
Re: Drop down menu with unserlize function ?
by trabis on 2008/5/18 22:11:04

You can test diferent outputs this way:
<?php $countries = 'a:2:{i:0;s:7:"abruzzo";i:1;s:10:"basilicata";}'; //$countries = 'a:2:{s:5:"milan";s:6:"Milano";s:6:"naples";s:6:"Napoli";}'; $data = unserialize($countries); foreach ($data as $key=>$value){ echo $key.' -> '.$value.'<br />'; } ?>


As you see one uses keys and the other does not.
Re: Drop down menu with unserlize function ?
by trabis on 2008/5/18 21:56:00

le="color: #000000"><?php $countries = 'a:2:{i:0;s:7:"abruzzo";i:1;s:10:"basilicata";}'; $data = unserialize($countries); echo $data[0];//abruzzo echo $data[1];//basilicata
Re: Drop down menu with unserlize function ?
by slyss on 2008/5/18 21:34:07

hi marco


if i have this:


le="color: #000000"><?php $countries = 'a:2:{i:0;s:7:"abruzzo";i:1;s:10:"basilicata";}';


how i can extract countries?

thanks a lot

Who's Online

202 user(s) are online (139 user(s) are browsing Support Forums)


Members: 0


Guests: 202


more...

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits