I have database MySQL and in one of the tables fields I have a suggestions which have values like this “13095,11413,11424,11434” or “1344,14513,11423”
The number in the values are my productID, ok now I need to do a while loop for each number and print it in a table, I can do the while loop to retrieve the product information, but how could I get the numbers each one alone to do the retrieving? I thought that if I used array I may solve the problem I used
PHP:
$sug = $row['SuggestProduct'];
$asug = array($sug);
but here array[0] = "13095,11413,11424,11434"
While explode is your friend, you should consider storing the suggestions differently. Do some research on “many to many” relations.
Solution for the above program is
$suggestions = explode(',', $row['SuggestProduct']);