5

In simple search form,if we search 1232 we get word stored as in given table we get cat from db using simple query select 'word' from 'dawat' where counting ='%$term%' samely 2454 for dog and so on. Form code:

<form action="upload.php" method="get" >
    <input type="file" name="fileToUpload" id="fileToUpload">
    <input type="submit" value="submit" name="submit">
</form>

and tables in db:

counting  word

1232      cat
2454      dog
4844      fish
7785      goat

Now,it is working correctly,problem is if multiple queries have same value how can we store in mysql.Suppose, all different no. have same value i.e. cat,so we can store normally like:

counting  word

1232      cat
2454      cat
4844      cat
7785      cat

This is how we can make different coloumns for single.Now,main question is how can i assign all different to fetch cat storing in single coloumn like:

   counting             word

1232,2454,4844,7785      cat

5785,4577,9644,6549      dog
125fura
  • 383
  • 2
  • 13

1 Answers1

0

Please try something of this sort (edited):

SELECT 
  GROUP_CONCAT(dawat.counting SEPARATOR ',') AS counting, 
  dawat.word
FROM
  dawat
GROUP BY
  dawat.word;

in case concatenated values should be ordered you could use this version:

SELECT 
  GROUP_CONCAT(dawat.counting ORDER BY dawat.counting ASC SEPARATOR ',') AS counting, 
  dawat.word
FROM
  dawat
GROUP BY
  dawat.word;
  • 1
    But tab,name how to replace as in like full table name searchengine or like counting/word as i described in question?Pls help i 'm new to php. – 125fura Dec 29 '14 at 08:21
  • Sorry, I missed the fact you gave table name `dawat` at the beginning of your question. –  Dec 29 '14 at 08:30
  • Ok,i got a idea.I had tried this also and your anwer also http://stackoverflow.com/questions/13451605/how-to-use-group-concat-in-a-concat-in-mysql – 125fura Dec 29 '14 at 08:31
  • So I'm glad you got the help needed - I hope a complete one –  Dec 29 '14 at 08:33