Reputation: 11
i'm a newbie in php and Mysql. I've got a table called 'cat_filter' done like 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 this code :
$connessione=mysql_connect($db_host,$db_user,$db_password);
mysql_select_db($db_database,$connessione);
$data = mysql_query("SELECT * FROM cat_filter WHERE 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, but i'd like taht if a field has more value separeted by this ';' the output will be separated for each (sorry for my english) .. is it clear ? Thanx in advance ! best regards. Francesco
Upvotes: 1
Views: 717
Reputation: 191729
Change the echo '' . $info['cat_filter_value']
line to perform a loop:
foreach (explode(';', $info['cat_filter_value']) as $value) {
echo $value . ": ...";
}
Upvotes: 1