[PHP-DB] mssql problems

2002-04-19 Thread Rob Fraser

Dear All,
I hope somebody can help me. I am new to PHP (I've used ASP for three
years:-( ) and I'm loving PHP and trying to get my work to convert but
I've coming across a error with mssql_query() explorer its just crashes
with a php.exe 'memory could not be read error'. I'm sure it a school
boy error from me but I'm just stuck, please help me code is..
===
$link = mssql_connect (laptop, sa, elmwood);
print (brLINK was $link);
 
$back = mssql_select_db ( elmback,$link); 
print(brback was $back);
 
$query = SELECT * FROM tblperson;
print(brquery was $query);
 
$result = mssql_query($query,$link); //JUST CRASHES ON THIS LINE
 
$r = mssql_rows_affected ( $link);
print(brrows affected was $r);
 
$close =  mssql_close ($link);
print(brclose was $close);
 
 
=
I run IIS4, NT4 (SP6a) and SQL 7 on the same machine as its my
development one, out of date maybe but you should see my clothes but PHP
was test downloaded a month ago - any ideas from a white knight?
best regards 
Rob

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Connection error

2002-04-19 Thread Ciprian Trofin

 Bisexuality doubles the chance of getting a date.


Hi All!
In order to make my job easy, a choose the following approach:

settings.php
?
$dbserver = 'server';
$dbname = 'name';
$dbpass = 'password';
?

main_file.php
?
include settings.php;
mysql_connect($dbserver,$dbname,$dbpass) or die (Error);
?

On the test machine (Windows 98, PHP Triad 221 - PHP 4.1.0) it works;
when I put the project online, it doesn't (the Error message shows up). If I
don't use this approach and, in main_file.php, I use the line:
  mysql_connect('server','name','pass') or die (Error)
the sistem works.

What's the problem ?

-- 
 Ciprian


 Confucius Says: Man who fight with wife all day, get no piece at night!


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Connection error

2002-04-19 Thread Jason Wong

On Friday 19 April 2002 18:29, Ciprian Trofin wrote:
  Bisexuality doubles the chance of getting a date.

 Hi All!
 In order to make my job easy, a choose the following approach:

 settings.php
 ?
 $dbserver = 'server';
 $dbname = 'name';
 $dbpass = 'password';
 ?

 main_file.php
 ?
 include settings.php;
 mysql_connect($dbserver,$dbname,$dbpass) or die (Error);
 ?

 On the test machine (Windows 98, PHP Triad 221 - PHP 4.1.0) it
 works; when I put the project online, it doesn't (the Error message shows
 up). If I don't use this approach and, in main_file.php, I use the line:
   mysql_connect('server','name','pass') or die (Error)
 the sistem works.

 What's the problem ?

Always check for errors. Use mysql_error() to see what the error is. Also try 
connecting to mysql from the shell/command-line.


-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *


/*
It isn't easy being the parent of a six-year-old.  However, it's a pretty 
small
price to pay for having somebody around the house who understands computers.
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Re:[PHP-DB] Connection error

2002-04-19 Thread adi

Ciprian Trofin [EMAIL PROTECTED] wrote on 4/19/2002 
5:29:00 PM: 

 Bisexuality doubles the chance of getting a date.


Hi All!
In order to make my job easy, a choose the following approach:

settings.php
?
$dbserver = 'server';
$dbname = 'name';
$dbpass = 'password';
?

main_file.php
?
include settings.php;
@mysql_connect($dbserver,$dbname,$dbpass) or die (Error);
?

On the test machine (Windows 98, PHP Triad 221 - PHP 4.1.0) it 
works; 
when I put the project online, it doesn't (the Error message shows 
up). If I don't use this approach and, in main_file.php, I use the 
line: 
  @mysql_connect('server','name','pass') or die (Error)
the sistem works.

What's the problem ?

try double quote instead single quote.
$dbserver = server;

_
adi.baliroomfinder.net


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Re:[PHP-DB] Connection error

2002-04-19 Thread Ciprian Trofin

 Monday is an awful way to spend 1/7th of your life.

a try double quote instead single quote.
a $dbserver = server;
Tried that, no effect.

-- 
 Ciprian


 Oxymoron: Government budget


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Connection error

2002-04-19 Thread Sam Masiello


Instead of suppressing the error message using the @ sign, why not
remove it and your die() statement and see what error is produced on
your live server?

HTH

--Sam


-Original Message-
From: Ciprian Trofin [mailto:[EMAIL PROTECTED]] 
Sent: Friday, April 19, 2002 6:29 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Connection error

 Bisexuality doubles the chance of getting a date.


Hi All!
In order to make my job easy, a choose the following approach:

settings.php
?
$dbserver = 'server';
$dbname = 'name';
$dbpass = 'password';
?

main_file.php
?
include settings.php;
@mysql_connect($dbserver,$dbname,$dbpass) or die (Error);
?

On the test machine (Windows 98, PHP Triad 221 - PHP 4.1.0) it
works;
when I put the project online, it doesn't (the Error message shows
up). If I
don't use this approach and, in main_file.php, I use the line:
  @mysql_connect('server','name','pass') or die (Error)
the sistem works.

What's the problem ?

-- 
 Ciprian


 Confucius Says: Man who fight with wife all day, get no piece at
night!


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] PHP Compiling issues

2002-04-19 Thread Chris O'Brien

Background:
Server version: Apache/1.3.24 (Darwin)
MySQL:  Ver 8.23 Distrib 3.23.49, for apple-darwin5.2 on powerpc
PHP version 4.1.2 from the Darwin CVS repository

--

After much hassle and grief, I was able to make and install PHP 4.1.2 
from the Darwin CVS source repository using this configure syntax:

./configure --with-mysql=/usr/local/mysql \
--with-apxs=/usr/sbin/apxs \
--with-curl=/sw \
--with-zlib-dir=/usr/local \
--with-pear

However, when I ran 'apachectl configtest' I got a bunch of errors 
dealing with Undefined symbols, all of them starting with _mysql_*

So, after doing some searching investigating, I re-ran the configure 
script with the following flags:

./configure --with-mysql=shared,/usr/local/mysql \
--with-apxs=/usr/sbin/apxs \
--with-curl=/sw \
--with-zlib-dir=/usr/local \
--with-pear

but when I ran make, the following errors showed:

*** Warning: This library needs some functionality provided by 
-lmysqlclient.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have.

*** Warning: libtool could not satisfy all declared inter-library
*** dependencies of module mysql.  Therefore, libtool will create
*** a static module, that should work as long as the dlopening
*** application is linked with the -dlopen flag.

but since the make wsa able to finish, I decided to try make install and 
see what happens. Upon running 'apachectl configtest' again, I  got 
Syntax OK, as expected. What I want to know is, will the issues 
mentioned in the errors cause me any troubles down the road? Or can 
these errors be safely ignored. The intended use for this server is as a 
test platform, and it will not come under any type of heavy load.

Please cc me, as I am in digest mode. TIA

chris


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] RE: troubles with select * from... to a ms-sql-server

2002-04-19 Thread Oliver Cronk

Have you tried removing the [] brackets?  And what is ReferencesComplete - a
standard table, a view or a stored procedure?

Ollie

-Original Message-
From: Hermann Otteneder [mailto:[EMAIL PROTECTED]]
Sent: 17 April 2002 16:30
To: [EMAIL PROTECTED]
Subject: troubles with select * from... to a ms-sql-server


hi,
i try to get some data from our ms-sql-server the following statement:

   $SQL = SELECT * FROM [ReferencesComplete];

causes an error of the php.exe! i tried many various of this statement but
nothing helped. ether it came no error and the [$result =
mssql_query($SQL,$IDconnection);] variable was false or the php.exe crashed!
with mysql it workes ok but with the ms-sql-server not!

please give me help - this so what simple - but does not work - i lost so
much time...

hermann





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] RE: mssql problems

2002-04-19 Thread Oliver Cronk

Hi PHP Is quite cool isn't it As for your problem you might want to try
a few things:

- Running PHP as the ISAPI module  make sure you have the latest version
(you should get the latest version anyway).
- Removing this line : $r = mssql_rows_affected ( $link); - as there is a
mysql function for this but not mssql - it should have read -
mssql_rows_affected($result) anyway I believe - it works on the result
rather than the connection).

Can't really think of any thing else without more info, although I've had
bad experiences with trying to run MSSQL / IIS on the same NT4 box (although
on 2000 and XP it's fine) - one of my colleages solution was to run Apache
for win32 instead of IIS as there appeared to be clashes between SQL and IIS
(something we have since rectified).

Good luck

Ollie

-Original Message-
From: Rob Fraser [mailto:[EMAIL PROTECTED]]
Sent: 19 April 2002 08:44
To: [EMAIL PROTECTED]
Subject: mssql problems


Dear All,
I hope somebody can help me. I am new to PHP (I've used ASP for three
years:-( ) and I'm loving PHP and trying to get my work to convert but
I've coming across a error with mssql_query() explorer its just crashes
with a php.exe 'memory could not be read error'. I'm sure it a school
boy error from me but I'm just stuck, please help me code is..
===
$link = mssql_connect (laptop, sa, elmwood);
print (brLINK was $link);

$back = mssql_select_db ( elmback,$link);
print(brback was $back);

$query = SELECT * FROM tblperson;
print(brquery was $query);

$result = mssql_query($query,$link); //JUST CRASHES ON THIS LINE

$r = mssql_rows_affected ( $link);
print(brrows affected was $r);

$close =  mssql_close ($link);
print(brclose was $close);


=
I run IIS4, NT4 (SP6a) and SQL 7 on the same machine as its my
development one, out of date maybe but you should see my clothes but PHP
was test downloaded a month ago - any ideas from a white knight?
best regards
Rob



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] page expires

2002-04-19 Thread Oliver Cronk

How about this incorporated somewhere:

$s = (SERVER_PROTOCOL == HTTP/1.0) ? Pragma: no-cache : Cache-Control:
no-cache, must-revalidate;
header($s);

This code must be at the start of the script  BEFORE anything is output to
the browser - as it sends an additional HTTP header (hence the function
header()).

Hope that helps

Ollie



-Original Message-
From: Jonathan Hilgeman [mailto:[EMAIL PROTECTED]]
Sent: 18 April 2002 19:37
To: 'Natividad Castro';
Subject: RE: [PHP-DB] page expires


http://php.sitecreative.com/faq.php


-Original Message-
From: Natividad Castro [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 17, 2002 6:12 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] page expires


Hi to all,

I have form that users fill out and submit. What I'm trying to do is not to
let users to go back to the form after they have submmited, or if they go
bak, make the page expires.
Can someone please tell me or give an idea on how to do it?

Thanks in advanced
Nato


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Date of Birth From Form

2002-04-19 Thread Brandon Paul

Hey all,

I have a credit application form, and one of the required elements is the
applicant's Date of Birth.  I have creditapp table with a birthdate
field and it is a DATE datatype.  On the form, I want to be able to have
them enter their Date of Birth as mm/dd/ and have it go into the
database properly (-mm-dd).  Is there a way to do it this way, or am I
going about it wrong?  Any help would be greatly appreciated.

Thanks!

Brandon



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Date of Birth From Form

2002-04-19 Thread Duncan Hill

On Fri, 19 Apr 2002, Brandon Paul wrote:

 going about it wrong?  Any help would be greatly appreciated.

1) Validate that the input is correct.
2) Tokenize the string based on the /s
3) Re-format the date.

Or, use the date functions - I'd swear one of them can re-write dates.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Date of Birth From Form

2002-04-19 Thread Steve Cayford

A combination of strtotime() and date() can make this easy.

date(Y-m-d, strtotime($birthday))

Or see docs and comments at 
http://www.php.net/manual/en/function.strtotime.php

-Steve

On Friday, April 19, 2002, at 01:29  PM, Brandon Paul wrote:

 Hey all,

 I have a credit application form, and one of the required elements is 
 the
 applicant's Date of Birth.  I have creditapp table with a birthdate
 field and it is a DATE datatype.  On the form, I want to be able to have
 them enter their Date of Birth as mm/dd/ and have it go into the
 database properly (-mm-dd).  Is there a way to do it this way, or 
 am I
 going about it wrong?  Any help would be greatly appreciated.

 Thanks!

 Brandon



 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] IP Address?

2002-04-19 Thread Rob Day

How can I find out the IP address of the client requesting a given php file?
I know that you can use $HTTP_SERVER_VARS[REMOTE_ADDR] in more recent
versions of PHP. Unfortunately, we only have PHP3.0.14 and I don't think
that this option is available in our ancient version. I also can't use
server side includes. An upgrade to PHP4 is in the works, but I can't wait
that long. How can I get a client's IP address with PHP3.014 and/or
JavaScript? Thanks in advance.
-Rob

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] IP Address?

2002-04-19 Thread Craig Vincent

 How can I find out the IP address of the client requesting a
 given php file?
 I know that you can use $HTTP_SERVER_VARS[REMOTE_ADDR] in more recent
 versions of PHP. Unfortunately, we only have PHP3.0.14 and I don't think
 that this option is available in our ancient version. I also can't use
 server side includes. An upgrade to PHP4 is in the works, but I can't wait
 that long. How can I get a client's IP address with PHP3.014 and/or
 JavaScript? Thanks in advance.

I believe

$ip = getenv('REMOTE_ADDR');

will do what you want.



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] IP Address?

2002-04-19 Thread Rob Day

Thanks, Craig. That was exactly what I was looking for!
-Rob

-Original Message-
From: Craig Vincent [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 19, 2002 2:35 PM
To: Rob Day; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] IP Address?


 How can I find out the IP address of the client requesting a
 given php file?
 I know that you can use $HTTP_SERVER_VARS[REMOTE_ADDR] in more recent
 versions of PHP. Unfortunately, we only have PHP3.0.14 and I don't think
 that this option is available in our ancient version. I also can't use
 server side includes. An upgrade to PHP4 is in the works, but I can't wait
 that long. How can I get a client's IP address with PHP3.014 and/or
 JavaScript? Thanks in advance.

I believe

$ip = getenv('REMOTE_ADDR');

will do what you want.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] IP Address?

2002-04-19 Thread Boaz Yahav

?
phpinfo();
?

 should give you all of the info you need.

Sincerely

  berber

Visit http://www.weberdev.com Today!!! 
To see where PHP might take you tomorrow.


-Original Message-
From: Rob Day [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 19, 2002 9:29 PM
To: 'Craig Vincent'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] IP Address?


Thanks, Craig. That was exactly what I was looking for!
-Rob

-Original Message-
From: Craig Vincent [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 19, 2002 2:35 PM
To: Rob Day; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] IP Address?


 How can I find out the IP address of the client requesting a
 given php file?
 I know that you can use $HTTP_SERVER_VARS[REMOTE_ADDR] in more
recent
 versions of PHP. Unfortunately, we only have PHP3.0.14 and I don't
think
 that this option is available in our ancient version. I also can't use
 server side includes. An upgrade to PHP4 is in the works, but I can't
wait
 that long. How can I get a client's IP address with PHP3.014 and/or
 JavaScript? Thanks in advance.

I believe

$ip = getenv('REMOTE_ADDR');

will do what you want.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Help with a JOIN statement

2002-04-19 Thread Michael Robbins

I have 2 tables, 'users' and 'files' (defined below)

Can I construct a single SELECT statement so that it will return ONLY
users that have files and ONLY the last file that the user has?  So it
would return 1 row per user containing their most recent file.

users

Id  int
Namevarchar

Files

Id  int
Userid  int
Filenamevarchar
Stamp   int (unix_timestamp)

The way I'm doing it now, I use SELECT DISTINCT to get all the users
with files, then a separate query for each user returned to retrieve
their latest file.  This method requires many, many individual queries
to the database?

Any help is appreciated.

Thanks,
Mikey


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Help with a JOIN statement

2002-04-19 Thread Robert V. Zwink

You could try:

SELECT users.Name, Files.Filename
  FROM Files
  LEFT JOIN users ON Files.Userid = users.Id
  GROUP BY Files.Userid
  ORDER BY Files.Stamp DESC

I'm not sure if this would work, depends on if MySQL ORDER's before GROUP.
You could try it though.  Capitolization may be incorrect, I tried to use
your convention, but I may have missed something.

Robert V. Zwink
http://www.zwink.net/daid.php

-Original Message-
From: Michael Robbins [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 19, 2002 4:55 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Help with a JOIN statement


I have 2 tables, 'users' and 'files' (defined below)

Can I construct a single SELECT statement so that it will return ONLY
users that have files and ONLY the last file that the user has?  So it
would return 1 row per user containing their most recent file.

users

Id  int
Namevarchar

Files

Id  int
Userid  int
Filenamevarchar
Stamp   int (unix_timestamp)

The way I'm doing it now, I use SELECT DISTINCT to get all the users
with files, then a separate query for each user returned to retrieve
their latest file.  This method requires many, many individual queries
to the database?

Any help is appreciated.

Thanks,
Mikey


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Re: mssql problems

2002-04-19 Thread Frank Flynn

I had this exact same problem and after a lot of time I switched to an ODBC
connection (no mssql_connect...  Just use the ODBC commands) and everything
has worked flawlessly since.

There's probably some right combination and way to use the mssql specific
commands but life it too short and the ODBC stuff will do everything you
need anyway.  It worked first time and every time since for me.

Good Luck,
Frank

On 4/19/02 1:54 PM, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:

 -Original Message-
 From: Rob Fraser [mailto:[EMAIL PROTECTED]]
 Sent: 19 April 2002 08:44
 To: [EMAIL PROTECTED]
 Subject: mssql problems
 
 
 Dear All,
 I hope somebody can help me. I am new to PHP (I've used ASP for three
 years:-( ) and I'm loving PHP and trying to get my work to convert but
 I've coming across a error with mssql_query() explorer its just crashes
 with a php.exe 'memory could not be read error'. I'm sure it a school
 boy error from me but I'm just stuck, please help me code is..
 ===
 $link = mssql_connect (laptop, sa, elmwood);
 print (brLINK was $link);
 
 $back = mssql_select_db ( elmback,$link);
 print(brback was $back);
 
 $query = SELECT * FROM tblperson;
 print(brquery was $query);
 
 $result = mssql_query($query,$link); //JUST CRASHES ON THIS LINE
 
 $r = mssql_rows_affected ( $link);
 print(brrows affected was $r);
 
 $close =  mssql_close ($link);
 print(brclose was $close);
 
 
 =
 I run IIS4, NT4 (SP6a) and SQL 7 on the same machine as its my
 development one, out of date maybe but you should see my clothes but PHP
 was test downloaded a month ago - any ideas from a white knight?
 best regards
 Rob


-- 
Frank Flynn
Poet, Artist  Mystic



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Complex (for me) table join - help please?

2002-04-19 Thread Peter Westergaard

I'm trying to perform a join that seems like it should be simple, but I'm just 
ending up in a morass.  Hopefully someone who's standing a step or two back from the 
problem can help me solve this one...

What I have:

Table A (Category): with a 3-tier category structure:
-Nature
-Category
-Sub-Category

Table B (Responsibility): with a reference to Table A, and a client id, and the id of 
a person responsible for that Sub-category for that client.
-TableA-id
-Client-id
-Person-id

So, what I want is a simple select which will fetch for me all rows in (Category) with 
the relevant person from (Responsibility) if there is one for a specific Client, but 
with a blank in that column if there isn't one. 

ie. (Category) has 10 entries (let's call them Ca-Cj), and (Responsibility) has 5 
entries for Client 1 (Ca,Cb,Cc,Cd,Ce) and 3 entries for Client 2 (Cd,Ce,Cf).

When I run the select for Client 1, I'd like to see... 
Ca - person
Cb - person
Cc - person
Cd - person
Ce - person
Cf - 
Cg - 
Ch - 
Ci - 
Cj - 

And when I run the same select for Client 2 I'd like to see:

Ca - 
Cb - 
Cc - 
Cd - person
Ce - person
Cf - person
Cg - 
Ch - 
Ci -
Cj - 

I tried a basic outer join type select, and of course for Client 1 I miss Cf, and 
when I use it for Client 2 I miss Ca-Cc.  

Anyone able to sort me out here?

I need to use a basic Select (instead of building a temp table or using variables in a 
PHP script) because another database process that I don't control needs to do the same 
thing.  

Think it's possible, or am I going to have to go and insert records into 
Responsibility for every entry in Category for every Client, resulting in 
(#Categories x #Clients) rows?  (The latter idea sure doesn't make me happy, but it 
would be 'easier' to build, if not to maintain.  (And, as you can appreciate, since 
I'm not the one maintaining it, I'm like THAT CLOSE from just going that way and 
saying 'screw em'!)

Hopefully,
-Peter Westergaard



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Complex (for me) table join - help please?

2002-04-19 Thread Mike

Peter,

I've you tried doing a inner join, left outer join, right outer join?

What db program are you using?

Could you post what your current select statement looks like?


Mike
- Original Message -
From: Peter Westergaard [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, April 19, 2002 5:46 PM
Subject: [PHP-DB] Complex (for me) table join - help please?


 I'm trying to perform a join that seems like it should be simple, but
I'm just ending up in a morass.  Hopefully someone who's standing a step or
two back from the problem can help me solve this one...

 What I have:

 Table A (Category): with a 3-tier category structure:
 -Nature
 -Category
 -Sub-Category

 Table B (Responsibility): with a reference to Table A, and a client id,
and the id of a person responsible for that Sub-category for that client.
 -TableA-id
 -Client-id
 -Person-id

 So, what I want is a simple select which will fetch for me all rows in
(Category) with the relevant person from (Responsibility) if there is one
for a specific Client, but with a blank in that column if there isn't one.

 ie. (Category) has 10 entries (let's call them Ca-Cj), and
(Responsibility) has 5 entries for Client 1 (Ca,Cb,Cc,Cd,Ce) and 3 entries
for Client 2 (Cd,Ce,Cf).

 When I run the select for Client 1, I'd like to see...
 Ca - person
 Cb - person
 Cc - person
 Cd - person
 Ce - person
 Cf -
 Cg -
 Ch -
 Ci -
 Cj -

 And when I run the same select for Client 2 I'd like to see:

 Ca -
 Cb -
 Cc -
 Cd - person
 Ce - person
 Cf - person
 Cg -
 Ch -
 Ci -
 Cj -

 I tried a basic outer join type select, and of course for Client 1 I
miss Cf, and when I use it for Client 2 I miss Ca-Cc.

 Anyone able to sort me out here?

 I need to use a basic Select (instead of building a temp table or using
variables in a PHP script) because another database process that I don't
control needs to do the same thing.

 Think it's possible, or am I going to have to go and insert records into
Responsibility for every entry in Category for every Client, resulting in
(#Categories x #Clients) rows?  (The latter idea sure doesn't make me happy,
but it would be 'easier' to build, if not to maintain.  (And, as you can
appreciate, since I'm not the one maintaining it, I'm like THAT CLOSE from
just going that way and saying 'screw em'!)

 Hopefully,
 -Peter Westergaard



 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.330 / Virus Database: 184 - Release Date: 2/28/02


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Complex (for me) table join - help please?

2002-04-19 Thread szii

Try

SELECT TableA.Category, TableB.PersonID
FROM TableA LEFT JOIN TableB ON (TableA.CategoryID = TableB.TableAID)
  WHERE TableB.ClientID = $cid
 ORDER BY TableA.Category ASC

LEFT JOIN states that you should return all TableA, inserting NULL for TableB
if there is no match.

'Luck

-Szii



- Original Message -
From: Peter Westergaard [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, April 19, 2002 2:46 PM
Subject: [PHP-DB] Complex (for me) table join - help please?


 I'm trying to perform a join that seems like it should be simple, but I'm just 
ending up in a morass.  Hopefully someone who's
standing a step or two back from the problem can help me solve this one...

 What I have:

 Table A (Category): with a 3-tier category structure:
 -Nature
 -Category
 -Sub-Category

 Table B (Responsibility): with a reference to Table A, and a client id, and the id 
of a person responsible for that Sub-category
for that client.
 -TableA-id
 -Client-id
 -Person-id

 So, what I want is a simple select which will fetch for me all rows in (Category) 
with the relevant person from (Responsibility)
if there is one for a specific Client, but with a blank in that column if there isn't 
one.

 ie. (Category) has 10 entries (let's call them Ca-Cj), and (Responsibility) has 5 
entries for Client 1 (Ca,Cb,Cc,Cd,Ce) and 3
entries for Client 2 (Cd,Ce,Cf).

 When I run the select for Client 1, I'd like to see...
 Ca - person
 Cb - person
 Cc - person
 Cd - person
 Ce - person
 Cf -
 Cg -
 Ch -
 Ci -
 Cj -

 And when I run the same select for Client 2 I'd like to see:

 Ca -
 Cb -
 Cc -
 Cd - person
 Ce - person
 Cf - person
 Cg -
 Ch -
 Ci -
 Cj -

 I tried a basic outer join type select, and of course for Client 1 I miss Cf, and 
when I use it for Client 2 I miss Ca-Cc.

 Anyone able to sort me out here?

 I need to use a basic Select (instead of building a temp table or using variables in 
a PHP script) because another database
process that I don't control needs to do the same thing.

 Think it's possible, or am I going to have to go and insert records into 
Responsibility for every entry in Category for every
Client, resulting in (#Categories x #Clients) rows?  (The latter idea sure doesn't 
make me happy, but it would be 'easier' to build,
if not to maintain.  (And, as you can appreciate, since I'm not the one maintaining 
it, I'm like THAT CLOSE from just going that way
and saying 'screw em'!)

 Hopefully,
 -Peter Westergaard



 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php