arrays - How to split value from mysql query in php -
i'm newbie in php , mysql. i've got table called 'cat_filter' done this
cat_filter_id cat_filter_value cat_filter_name categories_id 5 colore metallo bianco 13 2 tipologia schienale rete 11 3 finiture cromata 11 4 tipologia poltrona direzionale;operativa;visitatori 11
i've done code :
$connessione=mysql_connect($db_host,$db_user,$db_password); mysql_select_db($db_database,$connessione); $data = mysql_query("select * cat_filter categories_id=$current_category_id") or die(mysql_error()); echo '<p>'; while($info = mysql_fetch_array( $data )) { echo ''.$info['cat_filter_value'] . ': <a href="index.php?main_page=advanced_search_result&keyword='.$info['cat_filter_name'] . '&search_in_description=1&categories_id='.$current_category_id . '">'.$info['cat_filter_name'] . '</a> ~ '; } echo '</p>'; mysql_close();
the works quite well, i'd taht if field has more value separeted ';' output separated each (sorry english) .. clear ? thanx in advance ! best regards. francesco
change echo '' . $info['cat_filter_value']
line perform loop:
foreach (explode(';', $info['cat_filter_value']) $value) { echo $value . ": ..."; }
Comments
Post a Comment