[PHP-DB] how many queries?

2002-03-12 Thread dvigil

Is it possible to find out how many queries a particular persistent mysql
link has handled without keeping a separate running counter?

Daniel




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




[PHP-DB] Iterate through the resulting rows of a single column select statement.

2002-03-12 Thread Glenn Holden

I'm looking for a reasonably simple and fast way to fill an array with the
results of a single column select query.

example results from query:

+---+
| productid |
+---+
| PS|
| PSLEB |
| MD1   |
| CPSS1 |
| CPSG1 |
| CPSP1 |
| CPSSR |
| CPSGR |
| ST1   |
| STFREE|
+---+

desired array:
$arr = array(PS,PSLEB,MD1,CPSS1,CPSG1,CPSSR,CPSGR,ST1,STFREE);




I'm using PHP with MySQL.

I've seen ways to fill an array with an entire single row.  But I only need
one value from each row so mysql_query() and mysql_fetch_array() seem like
overkill.  Does anyone have a function that might do this already or a
suggestion to get me started?

Ultimate Goal:
Basically, I want to interate through a set of ID's returned by the select
query and perform further querys based on each id in the result.  An array
would be a clean way to step through it.  If there is a
better/simpler/easier way to do this, please let me know.  I'm new to PHP
(but not programming).

Thanks a bunch,
Glenn





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




Re: [PHP-DB] help php4.0.6&Oracle9i !

2002-03-12 Thread Steve Farmer

Hi varin,

  putenv("ORACLE_SID=TEST");

  $uid = "scott";
  $pwd = "tiger";
$inst = "test";
  $conn = ocilogon($uid,$pwd,"$inst");

works for me

you could also try

OCIInternalDebug(8);

and see what happens

I just noticed you are using Ora_logon, you need to use the OCI functions !!

HTH

steve
At 11:56 AM +0100 12/3/02, varin valery wrote:
>   I was successful in compiling php with the options --with-oracle
>and --with-oci8.
>   but when i tried to connect to the database with the instruction
>Ora_logon("user@tnsname", "password"), I got the following error message:
>   "Warning: Oracle: Connection Failed: Error while trying to retrieve
>text for error ORA-12154 in /home/httpd/html/tmp/testoracle9i.php on line 7"
>   I don't quite understand since I defined the environment variables
>ORACLE_HOME, ORACLE_SID and TNS_ADMIN
>
>
>
>
>
>
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

-- 
-
"Minds are like parachutes, they work best when open"
Support free speech; visit http://www.efa.org.au/

Heads Together Systems Pty Ltd http://www.hts.com.au
Email: [EMAIL PROTECTED] Tel: 612 9982 6767 Fax: 612 9981 3081 

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




Re: Re(2): Re(2): [PHP-DB] Fatal Error using mysql_connect()

2002-03-12 Thread Jason Wong

On Wednesday 13 March 2002 04:50, mailing list wrote:

> It compiled without any errors using -with-mysql=/usr
>
> However I still receive an error while trying to connect to my mysql
> database:
>
> Fatal error: Call to undefined function: mysql_connect() in
> /www/meyercousa/pages/view_data.php on line 13
>
> I have pasted my configuration from phpinfo().  Hope this helps

[snip]

> '--with-ldap=shared' '--with-mysql=shared' '--with-pgsql=shared'
> '--with-unixODBC=shared' '--with-apxs=/usr/sbin/apxs'



I'm confused as to what exactly you have done here. You say "it compiled 
without any errors using -with-mysql=/usr"

But then your config from phpinfo() shows:

  --with-mysql=shared



My advice is to do a clean installation: delete your current php src 
directory, extract the php tarball into a new directory then run

 configure
 make
 stop webserver
 make install
 restart webserver



-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk

/*
My only love sprung from my only hate!
Too early seen unknown, and known too late!
-- William Shakespeare, "Romeo and Juliet"
*/

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




[PHP-DB] RE: MS SQL problem with php

2002-03-12 Thread Oliver Cronk

What is the query / code that you are sending to MS-SQL in PHP?



-Original Message-
From: Daniel Ryhle [mailto:[EMAIL PROTECTED]]
Sent: 12 March 2002 21:42
To: [EMAIL PROTECTED]
Subject: MS SQL problem with php


I run MS SQL 2000 on a win 2k machine and IIS5. On this i have installed
php4.11 with php_mssql.dll support. When i do an insert query it works fine.

But my problem is with SELECT querys.

If i write a select query and run it on a table that is empty it works fine.

BUT if i put an entry into the table and run the same query again it just
stands and think until it time out. Extremely strange, cause ive programmed
some php against mysql on a linux machine and never had any troubles. But
this is totally...wacked..

Seems to work fine if i run the same querys directly in ms sql.

Is this a bug in php or is it perhaps just a configuration question or
somethin??

Extremely glad if someone had any info about this cause i need to get it to
work







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




[PHP-DB] compiling php for mysql on linux

2002-03-12 Thread mailing list

Hello,

I am still recieving errors when I try to connect to my MYSQL database
using php.

Here is the error that is generated on the page:

Fatal error: Call to undefined function: mysql_connect() in
/www/meyercousa/pages/view_data.php on line 13

As instructed from a previous post I recompiled php using the following
commands:

./configure --with-mysql=/usr/lib/mysql
(recieved the following error: "configure: error: Cannot find header files
under /usr/include/mysql")

./configure --with-mysql=/usr/include/mysql
(same error)

./configure --with-mysql=/usr
(as far as I can tell everything has compiled ok except I still recieve
the following error:  Fatal error: Call to undefined function:
mysql_connect() in /www/meyercousa/pages/view_data.php on line 13)

I have pasted the configuration command:

'./configure' 'i386-redhat-linux' '--prefix=/usr' '--exec-prefix=/usr'
'--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc'
'--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib'
'--libexecdir=/usr/libexec' '--localstatedir=/var'
'--sharedstatedir=/usr/com' '--mandir=/usr/share/man'
'--infodir=/usr/share/info' '--prefix=/usr' '--with-config-file-path=/etc'
'--enable-force-cgi-redirect' '--disable-debug' '--enable-pic'
'--disable-rpath' '--enable-inline-optimization' '--with-bz2'
'--with-curl' '--with-db3' '--with-dom=/usr' '--with-exec-dir=/usr/bin'
'--with-freetype-dir=/usr' '--with-gd' '--with-gdbm' '--with-gettext'
'--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-mm'
'--with-openssl' '--with-png' '--with-pspell' '--with-regex=system'
'--with-ttf' '--with-xml' '--with-expat-dir=/usr' '--with-zlib'
'--with-layout=GNU' '--enable-bcmath' '--enable-debugger' '--enable-ftp'
'--enable-magic-quotes' '--enable-safe-mode' '--enable-sockets'
'--enable-sysvsem' '--enable-sysvshm' '--enable-track-vars'
'--enable-trans-sid' '--enable-yp' '--enable-wddx' '--without-oci8'
'--with-imap=shared' '--with-imap-ssl' '--with-kerberos=/usr/kerberos'
'--with-ldap=shared' '--with-mysql=shared' '--with-pgsql=shared'
'--with-unixODBC=shared' '--with-apxs=/usr/sbin/apxs'

I hope this helps.

Regards,

Adrian


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




[PHP-DB] PLEASE HELP mysql_connect()!!!

2002-03-12 Thread Inter-Media Webmaster

PLEASE HELP !!!
HOW I CAN GET CONNETCTION TO REMOTE HOST IN OTHER SERVER WITH
mysql_connect();
e.g.
my php file is in www.abc.com/index.php
mysql server is in cgi.xyz.com on localhost

PLEASE ANSWER to [EMAIL PROTECTED]



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




Re(2): Re(2): [PHP-DB] Fatal Error using mysql_connect()

2002-03-12 Thread mailing list

[EMAIL PROTECTED] writes:
>Try:
>
>  -with-mysql=/usr
>
>
>-- 
>Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
>
>/*
>Absence diminishes mediocre passions and increases great ones,
>as the wind blows out candles and fans fires.
>   -- La Rochefoucauld
>*/
>
>-- 
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

It compiled without any errors using -with-mysql=/usr

However I still receive an error while trying to connect to my mysql
database:

Fatal error: Call to undefined function: mysql_connect() in
/www/meyercousa/pages/view_data.php on line 13

I have pasted my configuration from phpinfo().  Hope this helps

 './configure' 'i386-redhat-linux' '--prefix=/usr' '--exec-prefix=/usr'
'--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc'
'--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib'
'--libexecdir=/usr/libexec' '--localstatedir=/var'
'--sharedstatedir=/usr/com' '--mandir=/usr/share/man'
'--infodir=/usr/share/info' '--prefix=/usr' '--with-config-file-path=/etc'
'--enable-force-cgi-redirect' '--disable-debug' '--enable-pic'
'--disable-rpath' '--enable-inline-optimization' '--with-bz2'
'--with-curl' '--with-db3' '--with-dom=/usr' '--with-exec-dir=/usr/bin'
'--with-freetype-dir=/usr' '--with-gd' '--with-gdbm' '--with-gettext'
'--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-mm'
'--with-openssl' '--with-png' '--with-pspell' '--with-regex=system'
'--with-ttf' '--with-xml' '--with-expat-dir=/usr' '--with-zlib'
'--with-layout=GNU' '--enable-bcmath' '--enable-debugger' '--enable-ftp'
'--enable-magic-quotes' '--enable-safe-mode' '--enable-sockets'
'--enable-sysvsem' '--enable-sysvshm' '--enable-track-vars'
'--enable-trans-sid' '--enable-yp' '--enable-wddx' '--without-oci8'
'--with-imap=shared' '--with-imap-ssl' '--with-kerberos=/usr/kerberos'
'--with-ldap=shared' '--with-mysql=shared' '--with-pgsql=shared'
'--with-unixODBC=shared' '--with-apxs=/usr/sbin/apxs'


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




Re: Re(2): [PHP-DB] Fatal Error using mysql_connect()

2002-03-12 Thread Jason Wong

On Wednesday 13 March 2002 03:56, mailing list wrote:
> [EMAIL PROTECTED] writes:
> >Looks like MySQL support was not compiled into PHP.  If you are using a
> >linux based system you need to run the configure script with
> >the --with-mysql flag in order to utilize the MySQL function set.
> >
> >HTH
> >
> >Sam Masiello
> >Software Quality Assurance Engineer
> >Synacor
> >(716) 853-1362 X289
> >[EMAIL PROTECTED]
>
> Sam,
>
> I recompiled using the following commands ./configure
> --with-mysql=/usr/lib/mysql
>
> but I am getting the following error while it compiles:
>
> configure: error: Cannot find header files under /usr/lib/mysql


Try:

  -with-mysql=/usr


-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk

/*
Absence diminishes mediocre passions and increases great ones,
as the wind blows out candles and fans fires.
-- La Rochefoucauld
*/

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




RE: Re(2): [PHP-DB] Fatal Error using mysql_connect()

2002-03-12 Thread Hunter, Ray

Sometimes the include files are located in /usr/include/mysql

You might want to try there and see...Some times they are in /var/include
depending on the flavor of your OS



Thank you,

Ray Hunter
Firmware Engineer

ENTERASYS NETWORKS


-Original Message-
From: mailing list [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, March 12, 2002 12:57 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re(2): [PHP-DB] Fatal Error using mysql_connect()


[EMAIL PROTECTED] writes:
>
>Looks like MySQL support was not compiled into PHP.  If you are using a 
>linux based system you need to run the configure script with the 
>--with-mysql flag in order to utilize the MySQL function set.
>
>HTH
>
>Sam Masiello
>Software Quality Assurance Engineer
>Synacor
>(716) 853-1362 X289
>[EMAIL PROTECTED]

Sam,

I recompiled using the following commands ./configure
--with-mysql=/usr/lib/mysql

but I am getting the following error while it compiles:

configure: error: Cannot find header files under /usr/lib/mysql


Any ideas?

Regards,

Adrian


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



Re(2): [PHP-DB] Fatal Error using mysql_connect()

2002-03-12 Thread mailing list

[EMAIL PROTECTED] writes:
>
>Looks like MySQL support was not compiled into PHP.  If you are using a
>linux based system you need to run the configure script with
>the --with-mysql flag in order to utilize the MySQL function set.
>
>HTH
>
>Sam Masiello
>Software Quality Assurance Engineer
>Synacor
>(716) 853-1362 X289
>[EMAIL PROTECTED]

Sam,

I recompiled using the following commands ./configure
--with-mysql=/usr/lib/mysql

but I am getting the following error while it compiles:

configure: error: Cannot find header files under /usr/lib/mysql


Any ideas?

Regards,

Adrian


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




Re: [PHP-DB] Fatal Error using mysql_connect()

2002-03-12 Thread Sam Masiello


Looks like MySQL support was not compiled into PHP.  If you are using a
linux based system you need to run the configure script with
the --with-mysql flag in order to utilize the MySQL function set.

HTH

Sam Masiello
Software Quality Assurance Engineer
Synacor
(716) 853-1362 X289
[EMAIL PROTECTED]

- Original Message -
From: "mailing list" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, March 12, 2002 1:16 PM
Subject: [PHP-DB] Fatal Error using mysql_connect()


> Hello,
>
> I am receiving a fatal error on a php page:
>
> Fatal error: Call to undefined function: mysql_connect() in
> /www/meyercousa/pages/view_data.php on line 13
>
>
> My syntax on line 13 is: $db = mysql_connect('localhost', 'username',
> 'password');
>
> Anyone have any ideas?
>
> Regards,
>
> Adrian Mcmanus
> IT Director
> [EMAIL PROTECTED]
>
>
> --
> 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] Fatal Error using mysql_connect()

2002-03-12 Thread mailing list

Hello,

I am receiving a fatal error on a php page:

Fatal error: Call to undefined function: mysql_connect() in
/www/meyercousa/pages/view_data.php on line 13


My syntax on line 13 is: $db = mysql_connect('localhost', 'username',
'password');

Anyone have any ideas?

Regards,

Adrian Mcmanus
IT Director
[EMAIL PROTECTED]


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




[PHP-DB] Re: An interesting query that needs a different pair of eyes

2002-03-12 Thread John Hawkins

Hugh,

Thanks so much for the very detalied explanation. You
can bet I'll be saving it as reference for future
projects. Your solution worked perfectly!

As for the divisionID not being needed in both tables.
Ultimately, you are correct. I could easily get away
with connecting the tables together. But, this project
has a lot of pages that deal with one table at a time
so I found that it keeps my queries cleaner to have it
in both places. It may not be the cleanest code in the
world, but it works.

Thanks again for your help!

John


--- Hugh Bothwell <[EMAIL PROTECTED]> wrote:
> > What I'm trying to do is display a list of
> division
> > names assuming that each division has at least 2
> teams
> > associated with it.
> 
> 
> > table name #1: division
> > | ID | leagueID | name | rank |
> > | 1  | 1| Gold | 1|
> > | 2  | 1| Silver   | 2|
> > | 3  | 1| Bronze   | 3|
> > | 4  | 2| Level 1  | 1|
> > 
> > table name #2: team
> > | ID | leagueID | divisionID | name |
> > | 1  | 1| 1  | Vipers   | 
> > | 2  | 1| 1  | Warthogs |
> > | 3  | 1| 1  | Kings|
> > | 4  | 1| 2  | Ducks|
> 
> Note: I don't see why leagueID should appear
> in both tables; surely one of them is redundant?
> Does a division belong to a league?  And if so,
> surely a team belonging to a division will already
> belong to a league by implication?
> 
> 
> Instead of listing teams by division, I start by
> listing each division and its associated teams (if
> any):
> 
> SELECT division.name, team.name
> FROM division LEFT JOIN team ON division.id =
> team.divisionID
> 
> which gets me:
> 
> Gold | Warthogs
> Gold | Vipers
> Gold | Kings
> Silver | Ducks
> Bronze |
> Level 1 |
> 
> Note that there are no teams for Bronze or Level 1,
> but we still get the categories.  LEFT JOIN returns
> rows with NULL entries when there is no match.
> 
> I can use this to turn the team-existence condition
> into a number:
> 
> SELECT division.name, IF(team.name IS NULL,0,1) AS
> teams
> FROM division LEFT JOIN team ON division.id =
> team.divisionID
> 
> which gets me:
> 
> Gold | 1
> Gold | 1
> Gold | 1
> Silver | 1
> Bronze | 0
> Level 1 | 0
> 
> 
> The next step is obviously to sum these values:
> 
> SELECT division.name, SUM(IF(team.name IS NULL,0,1))
> AS teams
> FROM division LEFT JOIN team ON division.id =
> team.divisionID
> GROUP BY division.name
> 
> returning:
> 
> Gold | 3
> Silver | 1
> Bronze | 0
> Level 1 | 0
> 
> and finally a HAVING clause to filter:
> 
> SELECT division.name, SUM(IF(team.name IS NULL,0,1))
> AS teams
> FROM division LEFT JOIN team ON division.id =
> team.divisionID
> GROUP BY division.name
> HAVING teams >= 2
> 
> which leaves:
> 
> Gold | 3
> 
> 
> Voila!


__
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

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




[PHP-DB] conflicting result problem with MySQL/php

2002-03-12 Thread George Pitcher

Hi all,

I'm having a small problem with a biggish query.

The query:

$Itemlistquery= "select [a whole load of fields from 3 tables] ending with
";
$Itemlistquery.= "transactions.Pdownload ";
$Itemlistquery.= "from bib_extract,scanrates,transactions where ";
$Itemlistquery.= "(transactions.CourseID = '$Course_ID' and ";
$Itemlistquery.= "bib_extract.E_ID=transactions.ExtractID and ";
$Itemlistquery.= "scanrates.finrate=transactions.finrate) ";

The problem:

If I do a simple count of transactions.CourseID='$Course_ID' I get 18 (for a
particular course) and the above query only displays 3 results.

Any suggestions? I didn't want to clog the list with the whole query but I
can if it's necessary.

George, in Edinburgh


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




[PHP-DB] MS SQL problem with php

2002-03-12 Thread Daniel Ryhle

I run MS SQL 2000 on a win 2k machine and IIS5. On this i have installed
php4.11 with php_mssql.dll support. When i do an insert query it works fine.

But my problem is with SELECT querys.

If i write a select query and run it on a table that is empty it works fine.

BUT if i put an entry into the table and run the same query again it just
stands and think until it time out. Extremely strange, cause ive programmed
some php against mysql on a linux machine and never had any troubles. But
this is totally...wacked..

Seems to work fine if i run the same querys directly in ms sql.

Is this a bug in php or is it perhaps just a configuration question or
somethin??

Extremely glad if someone had any info about this cause i need to get it to
work





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




[PHP-DB] help php4.0.6&Oracle9i !

2002-03-12 Thread varin valery

  I was successful in compiling php with the options --with-oracle
and --with-oci8.
  but when i tried to connect to the database with the instruction
Ora_logon("user@tnsname", "password"), I got the following error message:
  "Warning: Oracle: Connection Failed: Error while trying to retrieve
text for error ORA-12154 in /home/httpd/html/tmp/testoracle9i.php on line 7"
  I don't quite understand since I defined the environment variables
ORACLE_HOME, ORACLE_SID and TNS_ADMIN







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




Re: [PHP-DB] An interesting query that needs a different pair of eyes

2002-03-12 Thread DL Neil

Howdy John,

Two things: firstly the stated objective and the sample query differ
(WHERE division.leagueID???). Secondly I'm sorry that I'm short of time
this morning, otherwise I'd try to develop/illustrate this for you...

May I suggest that you employ the KISS principle: Start off by coding a
simple join between the two tables to list every division and every team
within it - the way that you relate these two tables is a key to the
solution. Also doing that much will locate and correct one problem.

Then try adding the GROUP, and later add back the existing HAVING
clause. That should achieve the stated objective.

Thereafter you may reconsider that you don't even want to have the IF()
in there (I'm thinking, that you're thinking, that it will perform the
table join - but then I might be thinking something that you're not
thinking, and I think and you will also think, that such would be a
thankless thing)...

Let us know how you get on!
=dn



> What I'm trying to do is display a list of division
> names assuming that each division has at least 2 teams
> associated with it.
>
> Let's start with the table definitions:
>
> table name #1: division
>
> | ID | leagueID | name | rank |
> | 1  | 1| Gold | 1|
> | 2  | 1| Silver   | 2|
> | 3  | 1| Bronze   | 3|
> | 4  | 2| Level 1  | 1|
>
> table name #2: team
>
> | ID | leagueID | divisionID | name |
> | 1  | 1| 1  | Vipers   |
> | 2  | 1| 1  | Warthogs |
> | 3  | 1| 1  | Kings|
> | 4  | 1| 2  | Ducks|
>
> I created the following query:
>
> SELECT division.ID as curID, division.name, SUM(
> IF(team.divisionID = 'curID', 1, 0)) as teamcount
> FROM division, team
> WHERE division.leagueID = '1'
> GROUP BY division.ID
> having teamcount > 1
>
> This results in zero records.
>
> During some testing I found that, instead of trying to
> sum based on the "IF(team.divisionID = 'curID'", and
> instead used an actual value, like this:
> "IF(team.divisionID = '1'", that would produce
> results, but it would list every division name and the
> team count would be "3" in each row.
>
> I hope that was descriptive enough...
>
> Thanks in advance for your help!
>
> John
>
> __
> Do You Yahoo!?
> Try FREE Yahoo! Mail - the world's greatest free email!
> http://mail.yahoo.com/
>
> --
> 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




RE: [PHP-DB] Creating an array of mySQL results with PHP

2002-03-12 Thread Shrock, Court

You don't need to apologize for being new to PHP or for not understanding
what I have suggested.  We all have to start somewhere.  I fully understand
what you are trying to do--postnuke, as well as multiple sites of my own use
the method that I describe to do multiple row updates simultaneously.

The best way to really understand what is going on would be to run a simple
file (please bare with):

SNIP




EOD;
?>
SNIP


The above snippit works because the $data array is filled directly from the
form post.  But, when you want to fill the inputs from a database, your
data-source is different, but you can fudge it as the following code
demonstrates:

";
  foreach($data as $key => $val) {
echo "";
  }
  echo "";
}
printForm($_POST['data']);
?>


As you can see, the form has a variable number of elements whose names and
values match what is in the database the first time the script is run, but
take in the updated values when the form is submitted.  I hope this has
helped clear things up.

Here are some links that might shed some more light on the subject:
http://www.php.net/manual/en/language.variables.external.php
http://www.php.net/manual/en/language.variables.variable.php

Now that I have the sql and the source (output source of the demo), I can
code a complete loop for you, but I am tired (I am going on a 16 hours of
work now).  If you would be so kind as sending me demo/parent_log.php
(without passwords), that would save me the time of re-typing a lot if you
feel it would help you.

Court

> -Original Message-
> From: John Hughes [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, March 12, 2002 12:08 AM
> To: Shrock, Court; [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] Creating an array of mySQL results with PHP
> 
> 
> First, I admit to being VERY new to PHP and mySQL and, to make matters
> worse, I'm self-taught..
> 
> If you visit the demo site at http://fuzzheads.org/demo you 
> might better
> understand what I'm attempting to do and that might help 
> better explain my
> confusion with your suggestion.
> 
> The Parent Log displays the existing data for each week (up 
> to the current
> week, but not into the rest of the school year) divided into 
> eight possible
> types of work.
> 
> This is what the sql looks like:
> 
> $sql = "
>  SELECT weeks.*, parentlog.*
>  FROM weeks LEFT JOIN parentlog USING(week_no)
>  WHERE parentlog.parent_id = \"$parent_id\"
>  AND parentlog.student_id = \"$student_id\"
>  AND week_date <= CURRENT_DATE
>  ";
> 
> The _existing_ values are placed in the VALUE for each form 
> input in code
> like this:
> 
>  size=\"2\"
> maxlength=\"4\">
> Hidden values for the $week_no, $parent_id and $student_id 
> are included in
> each row.
> 
> Since I'm starting with the existing value for each field, 
> I'm confused by
> your suggestion that the name reference as an array would be 
> different from
> the value reference.
> 
> What I'm shooting for is the ability of the parent to change 
> any existing
> value in any field in any week and then press a single Update 
> button and
> have all of the values updated.
> 
> John Hughes
> 
> 
> - Original Message -
> From: "Shrock, Court" <[EMAIL PROTECTED]>
> To: "'John Hughes, Jomari Works'" <[EMAIL PROTECTED]>; "Shrock, Court"
> <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Monday, March 11, 2002 11:10 PM
> Subject: RE: [PHP-DB] Creating an array of mySQL results with PHP
> 
> 
> > Actually, you want the value of the input to be just 
> "$classroom".  That
> is
> > because it is within the while loop.  Can I ask for a little more
> > information regarding the structure of the table that you are
> querying--what
> > is(are) the primary keys in the table; I am assuming that 
> the "week_no"
> > field is the primary key.  I am sorry for the 
> confusion--the complete code
> > for outputting the input form follows (minus the 
> appropriate form tags).
> >
> > ###SNIP
> > echo "";
> > while ($row = mysql_fetch_array($result)) {
> >  $week_no = $row['week_no'];
> >  $week_date = $row['week_date'];
> >  $parent_id = $row['parent_id'];
> >  $student_id = $row['student_id'];
> >  $class_id = $row['class_id'];
> >  $classroom = $row['classroom'];
> >  $homework = $row['homework'];
> >  $library = $row['library'];
> >  $fieldtrip = $row['fieldtrip'];
> >  $pta = $row['pta'];
> >  $mast = $row['mast'];
> >  $meetings = $row['meetings'];
> >  $other = $row['other'];
> >
> >  echo << > 
> >> value=\"$classroom\">
> > 
> > EOD;
> >
> > }
> > echo "<";
> > ###SNIP
> >
> >
> > > -Original Message-
> > > From: John Hughes, Jomari Works [mailto:[EMAIL PROTECTED]]
> > > Sent: Monday, March 11, 2002 11:03 PM
> > > To: Shrock, Court; [EMAIL PROTECTED]
> > > Subject: Re: [PHP-DB] Creating an array of mySQL results with PHP
> > >
> > >
> > > OK. I can see how that works, assuming that the value would be
> > > \"log[$week_no][classroom]\" as well.
> > >
> > > What would the mysql_fetch_array look like?
> >
> > --
>