It's not a single record, it's 5 rows, in both cases. But with GROUP_CONCAT row count is zero even rows are visible!
Anyway I solved this with second query and with simple php comparison.
When adding GROUP_CONCAT to the query, row count is:
Showing rows 0 - 0 (1 total, Query took 0.0224 sec)
Without GROUP_CONCAT:
Showing rows 0 - 4 (5 total, Query took 0.0215 sec)
So in the first case mysql_num_rows() doesn't work anymore EVEN query result (via PHPMySQL) is OK!
Why row count is zero??
OK, I almost got it. With: ... SUM(quantity), SUM(importance) ... GROUP BY code,color ORDER BY importance desc
Output is now this:
[/td]IDcodedescriptionquantitycolorimportanceuseruser's comment
row1:1123item122black99
row2:2898item3999red88user1bbbbbb
row3:7777itemx3red56
row4:566item5555black4user1eeeeee
But as can you see, I'm missing users and their comments where data is grouped. How can I extract those too?
Sorry my bad explanation / english.
You can see in the data table that when code & color are the same, those items quantities are summed. Same thing with importance.
Not quantity + importance.
Like this:
user1's quantity + user4's quantity + user8's quantity
user1's importance + user4's importance + user8's importance
Output explained:
Row1 is the first because it has the highest importance value. And there's no other case where code is 123 AND color is black.
Rows2-4: Three users has code 898:s with red color. Total quantity (500+99+400) is 999 and total importance (30+50+ is 88.
Rows5-6: Two users has code 777:s with red color. Total quantity is (1 + 2) 3 and importance (26+30) value 56.
Row 7 is last because lowest importance value. And there's no other code 66 WITH black color.
A bit difficult (?) query. Is this even possible?
Quantity values and importance values is needed to add together if next user(s) code & color are the same.
But also I need to show user's comments for every individual data.
And sorted by importance.
Data:
IDcodedescriptionquantity colorimportanceusercomment
1123item122black99user1aaaaaa
2898item3500red30user1bbbbbb
3898item399red50user4cccccc
4898item3400red8user8dddddd
566item5555black4user1eeeeee
6777itemx1red26user9ffffff
7777itemx2red30user4gggggg
Output:
[/td]IDcodedescriptionquantitycolorimportanceuseruser's comment
row1:1123item122black99user1aaaaaa
row2:2898item3999red88user1bbbbbb
row3:user4cccccc
row4:user8dddddd
row5:7777itemx3red56user4gggggg
row6:user9ffffff
row5:566item5555black4user1eeeeee
I have been able to create that output with php (with mysql_data_seek and with a reqular query) but without "importance" sorting.
Thanks for your correction (didn't help ) but I think problem is more difficult.
There's lot of talk about onClick etc. not working in IE...especially IE6, but there must be a trick around this IE bug... at least for IE8.
I just need to open new location address when choosing an option.
I have this (one example created with php) :
<OPTION VALUE="54" onClick='window.location.href = "tedit.php?wt=1&wpt=54"';>blaablaa</OPTION>
and it works fine in Firefox, but not in IE.
Please tell me how to change it to make it work in both?
Thanks for the answers!
Actually problem was not \n, it was \r ...
Solved with this:
$exploded=explode("\r\n",$str); $str=$exploded[0]."\t\r";
But I'm curious why I can't put \n back? Like this:
$exploded=explode("\r\n",$str); $str=$exploded[0]."\t\r\n";
Doesn't work... but does it really need it?
I'm having trouble adding more tabs at the end of the line but BEFORE line feed.
I can find position of the line feed, but is there a function which can add text in string with position defined?
The string is like this:
"blaa\tblaa\t12345\tblaa\t*more tabs here*\n"
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.