php-windows Digest 16 Dec 2002 15:05:58 -0000 Issue 1489
Topics (messages 17417 through 17423):
Re: WebCalendar, IIS and mysql
17417 by: skyport
Arrays - I may have gone blind
17418 by: Aidal
17419 by: Seraphim
17420 by: Cam Dunstan
17423 by: Aidal
Re: need explanation about includes
17421 by: Seraphim
17422 by: Rich Gray
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Sure do, running good too, can be seen at
http://www.skyport.dynip.com/zforum/index.php?action=8 Calendar of Events
I can't remember what I did, but it works, sorry.
"Frode Mangseth" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
> Anyone managed to install WebCalendar 0.9.39 properly on Win2000 with
> IIS, MySQL and PHP 4.4.2?
> I can't get it to work without making alot of changes, but even then
> it doesn't function properly (login failure, sql faults...)
>
> Frode Mangseth
>
--- End Message ---
--- Begin Message ---
Hi NG.
I'm sure there is somthing implemented in PHP to do this but I just cant see
it.
I want to run through an array and remove some entries where <somthing 1> is
true and <somthing 2> is lower than the other entries of <somthing 1>
First i thought... hmm this sounds like a linked list, I'm gonna make one.
But I cant seem to make the list concept work properly with PHP, so I
thought that somthing might have been made for this.
Example:
for ($i = 0; $i < sizeof(some_db_result); $i++) {
array[$i]['id'] = this_db_result_row['id'];
array[$i]['type'] = this_db_result_row['type'];
array[$i]['v_id'] = this_db_result_row['v_id'];
}
// (id) is unique
// (type) is 1-4
// (v_id) is not unique.
What I want to do is to find all entries where (v_id) is the same and then
remove all but the one where (type) has the highest value.
How do I do this?
Or can a SQL statement do this in a DISTINCT like way? (SELECT table.id FROM
table WHERE somthing is = somthing else and a lot of other stuff BUT only
give me those where table.type has the hifgrst value)?
Please... need help with this
~ Aidal.
--- End Message ---
--- Begin Message ---
> Or can a SQL statement do this in a DISTINCT like way? (SELECT
> table.id FROM table WHERE somthing is = somthing else and a lot of
> other stuff BUT only give me those where table.type has the hifgrst
> value)?
>
> Please... need help with this
> ~ Aidal.
SELECT t1.id
FROM TABLENAME t1
WHERE t1.type = ( MAX (SELECT t2.type
FROM TABLENAME t2
WHERE t2,id = t1.id ) )
I think this would do what you want.
I'm also new at this and have never used this before, so it's likely to
contain some errors but if you do a google search you should be able to fish
those out.
good luck,
-Peter
--- End Message ---
--- Begin Message ---
aidal
Maybe the array_walk() function is for you - but in general terms it is
perhaps better to have a crack at a clever SQL statement if you are pulling
stuff out of a database in any case. Look at nested SELECT statements and
the MAX() function. Or, if not that, creating a temporary table with a
SELECT astatement then applying a second SELECT to that table???
----- Original Message -----
From: "Aidal" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, December 16, 2002 10:59 PM
Subject: [PHP-WIN] Arrays - I may have gone blind
> Hi NG.
>
> I'm sure there is somthing implemented in PHP to do this but I just cant
see
> it.
>
> I want to run through an array and remove some entries where <somthing 1>
is
> true and <somthing 2> is lower than the other entries of <somthing 1>
>
> First i thought... hmm this sounds like a linked list, I'm gonna make one.
> But I cant seem to make the list concept work properly with PHP, so I
> thought that somthing might have been made for this.
>
> Example:
>
> for ($i = 0; $i < sizeof(some_db_result); $i++) {
> array[$i]['id'] = this_db_result_row['id'];
> array[$i]['type'] = this_db_result_row['type'];
> array[$i]['v_id'] = this_db_result_row['v_id'];
> }
> // (id) is unique
> // (type) is 1-4
> // (v_id) is not unique.
>
> What I want to do is to find all entries where (v_id) is the same and then
> remove all but the one where (type) has the highest value.
> How do I do this?
> Or can a SQL statement do this in a DISTINCT like way? (SELECT table.id
FROM
> table WHERE somthing is = somthing else and a lot of other stuff BUT only
> give me those where table.type has the hifgrst value)?
>
> Please... need help with this
> ~ Aidal.
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
I have now tried the following statement:
SELECT annoncer.id,MAX(annoncer.type) AS maks,annoncer.virk_id FROM
annoncer,virksomheder
WHERE virksomheder.navn LIKE '%SomeWord%' AND virksomheder.id =
annoncer.virk_id
GROUP BY annoncer.virk_id ORDER BY virksomheder.navn
This almost works...
forget the "virksomheder" table it's not the essential here.
What i get from this is rows | id | maks | virk_id | where.
| id | - is the first known id for a given "virk_id"
| maks | - is the highes value of type for a given "virk_id"
| virk_id | - is the given virk_id
What i needed was (actually only needed the id):
| id | - where type has the highest value for a given "virk_id"
example table:
| id | virk_id | type | ("id" is unique, "virk_id" is not unique, "type" is
not unique)
-------------------
| 1 | 23 | 1 |
| 2 | 16 | 2 |
| 3 | 23 | 4 |
| 4 | 16 | 1 |
| 5 | 33 | 3 |
What I want out of this table would be the rows with id: 2,3 and 5
2 because "virk_id" is present twice but the row with id = 2 has the highest
"type" for "virk_id" = 16.
3 because "virk_id" is present twice but the row with id = 3 has the highest
"type" for "virk_id" = 23.
5 because "virk_id" is present only once so the value of type doesnt matter.
Does this make it easier for you to see what it is I'm trying to do here?
"Aidal" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi NG.
>
> I'm sure there is somthing implemented in PHP to do this but I just cant
see
> it.
>
> I want to run through an array and remove some entries where <somthing 1>
is
> true and <somthing 2> is lower than the other entries of <somthing 1>
>
> First i thought... hmm this sounds like a linked list, I'm gonna make one.
> But I cant seem to make the list concept work properly with PHP, so I
> thought that somthing might have been made for this.
>
> Example:
>
> for ($i = 0; $i < sizeof(some_db_result); $i++) {
> array[$i]['id'] = this_db_result_row['id'];
> array[$i]['type'] = this_db_result_row['type'];
> array[$i]['v_id'] = this_db_result_row['v_id'];
> }
> // (id) is unique
> // (type) is 1-4
> // (v_id) is not unique.
>
> What I want to do is to find all entries where (v_id) is the same and then
> remove all but the one where (type) has the highest value.
> How do I do this?
> Or can a SQL statement do this in a DISTINCT like way? (SELECT table.id
FROM
> table WHERE somthing is = somthing else and a lot of other stuff BUT only
> give me those where table.type has the hifgrst value)?
>
> Please... need help with this
> ~ Aidal.
>
>
--- End Message ---
--- Begin Message ---
Davide wrote:
> I have installed php-4.3.0 (I tried 4.2. but I couldn't make Apache2
> to run with it here in win32). Now I noticed a different behaviour in
> respect of 4.0.6 installed before.
> I use php_lib_login 0-9b to manage session login and I found it nice
> and quite reliable for my job; but when i went to test my scripts
> with new version of php i got no output from them. I disabled the
> include of php_lib_login and they are ok. After some trouble i found
> the problem: from php_lib_login :
> @include("php_lib_login_includes/adodb/adodb.inc.php"); // *
> @include("adodb/adodb.inc.php"); //ugly but prevents user from
> fiddling with paths
>
> @include("php_lib_login_includes/languages.inc.php"); // *
> @include("languages.inc.php");
>
> disabling the 2 lines I marked with * the scripts runs ok.
>
> Someone can tell me where is the problem? many thanks.
>
> N.B. If i put the entire scripts php_lib_login inline in my scripts
> all is ok without removing the two incudes.
> Davide.
PHP enters html mode when it includes a file. Perhaps the included files
don't start with <?php and don't end with ?>
Otherwise tell us what error message you receive.
-Peter
--- End Message ---
--- Begin Message ---
Do the 2 problematic includes include other files themselves?
Davide wrote:
> I have installed php-4.3.0 (I tried 4.2. but I couldn't make Apache2
> to run with it here in win32). Now I noticed a different behaviour in
> respect of 4.0.6 installed before.
> I use php_lib_login 0-9b to manage session login and I found it nice
> and quite reliable for my job; but when i went to test my scripts
> with new version of php i got no output from them. I disabled the
> include of php_lib_login and they are ok. After some trouble i found
> the problem: from php_lib_login :
> @include("php_lib_login_includes/adodb/adodb.inc.php"); // *
> @include("adodb/adodb.inc.php"); //ugly but prevents user from
> fiddling with paths
>
> @include("php_lib_login_includes/languages.inc.php"); // *
> @include("languages.inc.php");
>
> disabling the 2 lines I marked with * the scripts runs ok.
>
> Someone can tell me where is the problem? many thanks.
>
> N.B. If i put the entire scripts php_lib_login inline in my scripts
> all is ok without removing the two incudes.
> Davide.
--- End Message ---