hi there, i jus need ur a help . thing is that i have a category page where admin will make categories. there are two fields category_id and category_name. there is another form member directory where admin will make directory list. there are some clients whose multiple business so i am sending the category in array to the database they are saving like( 2,7,9 etc). but the thing is that i want to display in the user side where client A has this type of category business. e.g name- client name category of business - a,b,c (note that: a,b,c is the category id of 2,7,9) how will i display it from the database. i have tried a lot but cud nt get success. pls help me
What you do is correct. All you need to do to display the category names is something like this. $cats = explode(',',$data['catOfBusiness']); foreach ($cats as $cat) { $query = mysql_query('SELECT `name` FROM `categorieOfBusiness` WHERE `id`='.$cat.' LIMIT 1'; $data = mysql_fetch_assoc($query); echo $data['name']; } PHP: hope that helps;
Don't send category as array. Use normalization. Maybe this better So, user can have one or more category.