|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#16
|
|||
|
|||
|
That doesn't show all the details linked with each name it just shows each name with each detail.
If there is a name 3 times in the database with 3 different types of details that are search for it should show the name with 3 different types of details under it and then the count should be 3, the order should start with the names that has most details. Thanks for your help |
|
#17
|
|||
|
|||
|
This mite make it easier details is the same as criteria
|
|
#18
|
|||
|
|||
|
I got it to show the right details under the name but I can't get the div to end on the last details so it looks messed up any1 got any ideas??
PHP Code:
|
|
#19
|
|||
|
|||
|
if ($a1["Name"] != $fundn) <--- This must be false.
__________________
Sir, a desire of knowledge is the natural feeling of mankind; and every human being, whose mind is not debauched, will be willing to give all that he has to get knowledge. |
|
#20
|
|||
|
|||
|
In fact on second glance you set $fundn = $a1["Name"]; so of course the if ($a1["Name"] != $fundn) statement would be false, you can't say:
If 'X' != 'Y' then set 'X'='Y' and then expect 'X' to not equal 'Y' after you just set it equal to 'Y'. |
|
#21
|
|||
|
|||
|
PHP Code:
just set $fundn at the end. It would be equal to whatever the last iteration was. If name is different from the last iteration, then you echo the div stuff. |
|
#22
|
|||
|
|||
|
Nope still don't work, heres the code so far:
PHP Code:
The count works, but the div does not close in the right place it should close on the last echo $a1['Criteria']; for that "Name". Is there a way to put it in order so the Name with the highest count is at the top? Thanks Last edited by drewj2k : August 22nd, 2008 at 04:48 AM. |
|
#23
|
|||
|
|||
|
Can you post the HTML source of this page? I think what you mean is:
$count = 0; } echo $a1['Criteria']; echo "</div>"; //add 1 to the count. $count++; $fundnn = $a1["Name"]; |
|
#24
|
|||
|
|||
|
Quote:
Because you could have for example 3 criteria s listed there if you closed the div on the first criteria the second 2 wouldn't appear in the correct place if that makes any sense? |
|
#25
|
|||
|
|||
|
and if you wanted to sort by the name with the most details, you would probably need to do a subquery to get a count of how many details are under each name and sort by that.
PHP Code:
Then you can get rid of the $count variable and use the count from the query. |
|
#26
|
|||
|
|||
|
Thanks Ala but it does not order them by the count here is the query with my values:
PHP Code:
Can you check it is correct? Thanks |
|
#27
|
|||
|
|||
|
Also the count is showing weird numbers ?!
Here is all the code so far: PHP Code:
|
|
#28
|
|||
|
|||
|
oops, the count should be order desc.
ORDER BY `count` DESC, `Name` ASC, `Criteria` ASC |
|
#29
|
|||
|
|||
|
Haha the order is correct now but the count is still wrong I have weird numbers like:
29 29 29 29 29 27 27 25 24 when it should be like 4 4 4 3 3 3 2 2 I don't understand the sub query but It needs to count the amount of Criterias to each Name. Thanks Last edited by drewj2k : August 22nd, 2008 at 02:03 PM. |
|
#30
|
|||
|
|||
|
well you can still use the other $count method to get the correct count if you want, but it shouldn't be needed. The subquery should just get a count of how many rows share the name of the primary query. That should essentially get the count of how many criteria there are under that name. I guess though you would need to add the criteria part to that query too to get a count of how many match the criteria also. Try this:
PHP Code:
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Showing results for Mysql Query multiple results for each name |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|