i dont quite think i understand the question, but if you
want to fetch results as an array with mysql, do this:
$result = mysql_query( sql );
mysql_fetch_array($result);
-Original Message-
From: Chris Oxenreider [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 09, 2001 12:39 PM
To: [EMAIL PROTECTED]
Subject: [PHP] PHP array information.
Hello:
My apologies if this has been covered before, or if i have missed it on
the php manual web pages. I am looking for some information on how to do
a perl like array with a *sql call in PHP.
Here is what I want to do:
table:
problem_class
_rid (tinyint)
description (mediumtext)
Sample data:
_riddescription
1 open
2 closed
3 testing
10 S
11 M
12 L
13 XL
20 Black
21 Red
22 Green
23 Blue
In perl this might be accomplished by doing this:
(Note some pseudo code is used here. Assume mysql as database but
could be others like Oracle.)
$query = SELECT _rid,description FROM problem_class;
$q_pointer = sql_query($query);
@problem_class = sql_associate_array_get($q_pointer);
print select name=\status\\n;
for ($i = 0; $i 10 ; ++$i) {
if ( $problem_class[$i] ne ) {
print option value=\$i\ $problem_class[$i]\n;
}
}
print /select\n;
print select name=\size\\n;
for ($i = 10; $i 20 ; ++$i) {
if ( $problem_class[$i] ne ) {
print option value=\$i\ $problem_class[$i]\n;
}
}
print /select\n;
print select name=\color\\n;
for ($i = 20; $i 30 ; ++$i) {
if ( $problem_class[$i] ne ) {
print option value=\$i\ $problem_class[$i]\n;
}
}
print /select\n;
This produces something very close to this:
select name=status
option value=1 open
option value=2 closed
option value=3 testing
/select
select name=size
option value=10 S
option value=11 M
option value=12 L
option value=13 XL
/select
select name=color
option value=20 Black
option value=21 Red
option value=22 Green
option value=23 Blue
/select
If I could use something like this, it would allow me to produce different
'for' statements for each select drop down I wanted to create. One table
to maintain, and change encase politics force me to change some of
definitions with out having to do a massive sql update. This works as
long as the problem_class table is rather short (ie less than 1,000
records).
I know I am missing something 'obvious' in this. Your help is
appreciated. Thank you.
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Chris Oxenreider | [EMAIL PROTECTED] | http://www.state.net/~oxenreid
| MicroSoft Windows 2000: The De facto sub standard.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]