[PHP-DB] how to pull array out?

2002-05-30 Thread Jas

Not sure how to do this, but I need to pull the contents of an array into
editable text fields...  As of yet I have not found a way to accomplish
this:

$table = auth_users;
 $record = @mysql_query(SELECT * FROM $table WHERE user_id =
'$user_id',$dbh);
   while ($row = mysql_fetch_row($record)) {
$user_id = $row['user_id'];
$f_name = $row['f_name'];
$l_name = $row['l_name'];
$email_addy = $row['email_addy'];
$un = $row['un'];
$pw = $row['pw']; }
$var_form .= table width=\100%\ border=\0\ cellpadding=\7\form
name=\$user_id\ method=\post\ action=\del_account.php\
  trtd width=\20%\ colspan=\2\bEdit Account
$user_id/b/td/tr
trtd width=\20%\First Name:/tdtd width=\80%\input
type=\text\ name=\f_name\ size=\30\ maxlength=\30\
value=\$f_name\font class=\copyright\i.e. John/font/td/tr
trtd width=\20%\Last Name:/tdtd width=\80%\input
type=\text\ name=\l_name\ size=\30\ maxlength=\30\
value=\$l_name\font class=\copyright\i.e. Doe/font/td/tr
  trtd width=\20%\Email:/tdtd width=\80%\input
type=\text\ name=\email_addy\ size=\30\ maxlength=\30\
value=\$email_addy\font class=\copyright\i.e.
[EMAIL PROTECTED]/font/td/tr
trtd width=\20%\User Name:/tdtd width=\80%\input
type=\text\ name=\un\ size=\30\ maxlength=\30\ value=\$un\font
class=\copyright\i.e. j-doe/font/td/tr
trtd width=\20%\Password:/tdtd width=\80%\input
type=\password\ name=\pw\ size=\30\ maxlength=\30\font
class=\copyright\(password must be alpha-numeric, i.e.
pAs5w0rd)/font/td/tr
trtd width=\20%\Confirm Password:/tdtd
width=\80%\input type=\password\ name=\pw\ size=\30\
maxlength=\30\font class=\copyright\please confirm password
entered/font/td/tr
trtd width=\20%\nbsp;/tdtd width=\80%\input
type=\submit\ name=\add\ value=\edit user\nbsp;nbsp;input
type=\reset\ name=\reset\ value=\reset\/td/tr
   /form/table;
echo $record;

It only echoes the resource id, any help or examples would be great
Jas



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




Re: [PHP-DB] how to pull array out?

2002-05-30 Thread Jason Wong

On Friday 31 May 2002 00:19, Jas wrote:
 Not sure how to do this, but I need to pull the contents of an array into
 editable text fields...  As of yet I have not found a way to accomplish
 this:

Good grief, I already posted the answer yesterday. Don't you read the replies? 
Even if you don't, spending a little time googling for mysql php tutorial 
would get you numerous examples.

 $table = auth_users;
  $record = mysql_query(SELECT * FROM $table WHERE user_id =
 '$user_id',$dbh);

[snip]

 echo $record;

 It only echoes the resource id, any help or examples would be great

I repeat, mysql_query() returns a resource-id which you need to feed into 
mysql_fetch_array() to get the actual record.

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


/*
The chief danger in life is that you may take too many precautions.
-- Alfred Adler
*/


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




Re: [PHP-DB] how to pull array out?

2002-05-30 Thread Jas

Mr. Wong,
You are no help.  As you can probably see I am NOT an experienced php
developer!!  Posting to this list, reading the manual, and scouring sites
for tutorials is all I have to provide me with a way to maybe begin doing
writting php apps.  I did read your reply about feeding the results into an
array  however I have not been able to accomplish what I have set out to
do.  A GOOD EXPLANATION IS ALL WE NEED!!! You posting stuff on how we should
read the manual does not suffice!  People post to this newsgroup to get
answers to problems they cannot figure out.  I am sure you have been working
with php enough to know how to accomplish anything you need, and for the
rest of us we rely on examples, etc to get it done.  I appriciate you taking
the time to reply to mine and others posts, however if you do not have
anything nice to say please keep it to yourself.  I am trying to find an
answer to a problem and reading your RTFM does not help.  Thannks again,
Jas

Jason Wong [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Friday 31 May 2002 00:19, Jas wrote:
  Not sure how to do this, but I need to pull the contents of an array
into
  editable text fields...  As of yet I have not found a way to accomplish
  this:

 Good grief, I already posted the answer yesterday. Don't you read the
replies?
 Even if you don't, spending a little time googling for mysql php
tutorial
 would get you numerous examples.

  $table = auth_users;
   $record = @mysql_query(SELECT * FROM $table WHERE user_id =
  '$user_id',$dbh);

 [snip]

  echo $record;
 
  It only echoes the resource id, any help or examples would be great

 I repeat, mysql_query() returns a resource-id which you need to feed into
 mysql_fetch_array() to get the actual record.

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


 /*
 The chief danger in life is that you may take too many precautions.
 -- Alfred Adler
 */




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




RE: [PHP-DB] how to pull array out?

2002-05-30 Thread Leotta, Natalie (NCI/IMS)

OK, then.  Here's an example.  I understand that this is confusing (it took
me quite some time to get my first db example working correctly), but there
are normally examples on PHP.net if you look up the functions that Jason
referred you to.  If those didn't help I don't know how much help mine will
be, but at least I kind of explain it :-)

It's using Sybase, but the commands should be very similar to those for
other ones (I think all that changes is the first part).

For mine, here's how I set up $sql:
$countySql = SELECT a.Sex, a.AgeForCSR, a.Pop, b.strAgeForCSRDescription, 1
as id from tblPopCounty a, tlkpAgeForCSR b where a.StateFIPS = '$state' and
a.CountyFIPS = '$county' and a.Race = '$race' and a.$sqlAge and
a.AgeForCSR=b.AgeForCSR;

$stateSql =  SELECT a.Sex, a.AgeForCSR, a.Pop, b.strAgeForCSRDescription, 2
as id from tblPopState a,  tlkpAgeForCSR b where a.StateFIPS = '$state' and
a.Race='00' and a.$sqlAge and a.AgeForCSR=b.AgeForCSR;

$sql = $countySql .  UNION  . $stateSql;


so,
$array_ref[0] = Sex
$array_ref[1] = AgeForCSR
$array_ref[2] = Pop
$array_ref[3] = strAgeForCSRDescription
$array_ref[4] = id


***Here's where I actually read the rows that are identified by the result
and divide them up into 4 arrayes, based on gender and id***
$dataResult = sybase_query($sql);
while ($array_ref = sybase_fetch_row($dataResult)) {
//foreach ($a_row as $array_ref) { *** if you leave that in, you get
each item, not each row***
//print $array_ref . BR;
if ($array_ref[4] == 1) {
if ($array_ref[0] == $male ) {  
$left[$i] = $array_ref[2];
$names[$i] = $array_ref[3];
$ages[$i] = $array_ref[1];
$i++;   
}
elseif ($array_ref[0] == $female ) { 
$right[$j] = $array_ref[2];
$j++;
}
}
elseif ($array_ref[4]==2) {
if ($array_ref[0] == $male ) {  
$left2[$k] = $array_ref[2];
$names2[$k] = $array_ref[3];
$ages2[$k] = $array_ref[1];
$k++;   
}
elseif ($array_ref[0] == $female ) { 
$right2[$l] = $array_ref[2];
$l++;
}
}//elseif id==2 
//  }//foreach
}//while

-Original Message-
From: Jas [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, May 30, 2002 1:27 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] how to pull array out?


Mr. Wong,
You are no help.  As you can probably see I am NOT an experienced php
developer!!  Posting to this list, reading the manual, and scouring sites
for tutorials is all I have to provide me with a way to maybe begin doing
writting php apps.  I did read your reply about feeding the results into an
array  however I have not been able to accomplish what I have set out to
do.  A GOOD EXPLANATION IS ALL WE NEED!!! You posting stuff on how we should
read the manual does not suffice!  People post to this newsgroup to get
answers to problems they cannot figure out.  I am sure you have been working
with php enough to know how to accomplish anything you need, and for the
rest of us we rely on examples, etc to get it done.  I appriciate you taking
the time to reply to mine and others posts, however if you do not have
anything nice to say please keep it to yourself.  I am trying to find an
answer to a problem and reading your RTFM does not help.  Thannks again, Jas

Jason Wong [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Friday 31 May 2002 00:19, Jas wrote:
  Not sure how to do this, but I need to pull the contents of an array
into
  editable text fields...  As of yet I have not found a way to 
  accomplish
  this:

 Good grief, I already posted the answer yesterday. Don't you read the
replies?
 Even if you don't, spending a little time googling for mysql php
tutorial
 would get you numerous examples.

  $table = auth_users;
   $record = @mysql_query(SELECT * FROM $table WHERE user_id = 
  '$user_id',$dbh);

 [snip]

  echo $record;
 
  It only echoes the resource id, any help or examples would be 
  great

 I repeat, mysql_query() returns a resource-id which you need to feed 
 into
 mysql_fetch_array() to get the actual record.

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


 /*
 The chief danger in life is that you may take too many precautions.
 -- Alfred Adler
 */




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscrib

Re[2]: [PHP-DB] how to pull array out?

2002-05-30 Thread Julie Meloni

Jas (and anyone else) -

With all due respect, you're acting like a troll.  Posting a question,
getting MANY correct answers, then reposting the question and bitching
about not understanding the answers, well, that's troll-like.

Granted, many responses on this list over the past while have been
sarcastic, but usually also have the answer in them.  The tone comes
from people asking the questions not doing their own homework.

e.g. http://www.tuxedo.org/~esr/faqs/smart-questions.html

Mailing lists such as this one are not intended to give people
verbatim answers to their problems, such as I have to write an
application for my university class, please do it for me and the
like.  Instead, these lists will help those who attempt to help
themselves.

The fact of the matter is, RTFM is the right answer.  The very
simplistic method of reading the results of a MySQL query are right
there in the manual, in the MySQL query functions section.  Also,
they're in zillions of tutorials, any basic book on PHP, and so on.

In short:

1) connect to db server -- mysql_connect()
2) select db -- mysql_select_db()
3) issue query -- mysql_query()
4) from there you get a result identifier.  You feed that into
mysql_result() or mysql_fetch_array() or mysql_fetch_row()

Read the manual for the differences -- including examples.


You say:
J rest of us we rely on examples, etc to get it done.

They ARE in the manual, which is pretty much the best manual out there
for just about anything.

Good luck,
- Julie

-- Julie Meloni
-- [EMAIL PROTECTED]
-- www.thickbook.com

Find Sams Teach Yourself MySQL in 24 Hours at
http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20


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




Re[2]: [PHP-DB] how to pull array out?

2002-05-30 Thread Ed Gorski

Well put Julie

ed

At 10:39 AM 5/30/2002 -0700, Julie Meloni wrote:
Jas (and anyone else) -

With all due respect, you're acting like a troll.  Posting a question,
getting MANY correct answers, then reposting the question and bitching
about not understanding the answers, well, that's troll-like.

Granted, many responses on this list over the past while have been
sarcastic, but usually also have the answer in them.  The tone comes
from people asking the questions not doing their own homework.

e.g. http://www.tuxedo.org/~esr/faqs/smart-questions.html

Mailing lists such as this one are not intended to give people
verbatim answers to their problems, such as I have to write an
application for my university class, please do it for me and the
like.  Instead, these lists will help those who attempt to help
themselves.

The fact of the matter is, RTFM is the right answer.  The very
simplistic method of reading the results of a MySQL query are right
there in the manual, in the MySQL query functions section.  Also,
they're in zillions of tutorials, any basic book on PHP, and so on.

In short:

1) connect to db server -- mysql_connect()
2) select db -- mysql_select_db()
3) issue query -- mysql_query()
4) from there you get a result identifier.  You feed that into
mysql_result() or mysql_fetch_array() or mysql_fetch_row()

Read the manual for the differences -- including examples.


You say:
J rest of us we rely on examples, etc to get it done.

They ARE in the manual, which is pretty much the best manual out there
for just about anything.

Good luck,
- Julie

-- Julie Meloni
-- [EMAIL PROTECTED]
-- www.thickbook.com

Find Sams Teach Yourself MySQL in 24 Hours at
http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20


--
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: Re[2]: [PHP-DB] how to pull array out?

2002-05-30 Thread Jas

Ok, given there are people out there that expect people to do the work for
them, however if you look at my original post (today) you will see that I
have queried the database, feed the results into an array, then called the
array elements into my form, however simple this may be for you it is still
not pulling out the results of the array into my form.  I do believe I am
missing something, and doing homework is a part of my everyday routine
trying to develop web based apps.  The code again:

$table = auth_users; // names the table to query correct?
 $record = @mysql_query(SELECT * FROM $table WHERE user_id =
'$user_id',$dbh); // pulls all records in relation to $user_id correct?
   while ($row = mysql_fetch_array($record)) { // pulls results of query
into an array correct?
$user_id = $row['user_id']; // assigns unique names for my different
editable regions correct?
$f_name = $row['f_name'];
$l_name = $row['l_name'];
$email_addy = $row['email_addy'];
$un = $row['un'];
$pw = $row['pw']; }
$var_form .= form name=\$user_id\ method=\post\
action=\del_account.php\
  bEdit Account $user_id/bbr // echoes the $user_id that is going
to be edited correct?
First Name:input type=\text\ name=\f_name\ size=\30\
maxlength=\30\ value=\$f_name\br // displays text box to edit with
$f_name variable from resulting array correct?
Last Name:input type=\text\ name=\l_name\ size=\30\
maxlength=\30\ value=\$l_name\br // displays text box to edit with
$l_name variable from resulting array correct?
Email:input type=\text\ name=\email_addy\ size=\30\
maxlength=\30\ value=\$email_addy\br // displays text box to edit
with $email_addy variable from resulting array correct?
User Name:input type=\text\ name=\un\ size=\30\ maxlength=\30\
value=\$un\br  // displays text box to edit with $un variable from
resulting array correct?
Password:input type=\password\ name=\pw\ size=\30\
maxlength=\30\br // displays text box to edit with $pw variable from
resulting array correct?
Confirm Password:input type=\password\ name=\cpw\ size=\30\
maxlength=\30\
nbsp;input type=\submit\ name=\add\ value=\edit
user\nbsp;nbsp;input type=\reset\ name=\reset\ value=\reset\;

Any help or examples are appreciated.  Please understand I am trying to
learn this scripting language and RTFM does not help as most of the time I
post here as a LAST resort, i.e. after I have indeed RTFM'ed.
Thanks again,
Jas


Julie Meloni [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Jas (and anyone else) -

 With all due respect, you're acting like a troll.  Posting a question,
 getting MANY correct answers, then reposting the question and bitching
 about not understanding the answers, well, that's troll-like.

 Granted, many responses on this list over the past while have been
 sarcastic, but usually also have the answer in them.  The tone comes
 from people asking the questions not doing their own homework.

 e.g. http://www.tuxedo.org/~esr/faqs/smart-questions.html

 Mailing lists such as this one are not intended to give people
 verbatim answers to their problems, such as I have to write an
 application for my university class, please do it for me and the
 like.  Instead, these lists will help those who attempt to help
 themselves.

 The fact of the matter is, RTFM is the right answer.  The very
 simplistic method of reading the results of a MySQL query are right
 there in the manual, in the MySQL query functions section.  Also,
 they're in zillions of tutorials, any basic book on PHP, and so on.

 In short:

 1) connect to db server -- mysql_connect()
 2) select db -- mysql_select_db()
 3) issue query -- mysql_query()
 4) from there you get a result identifier.  You feed that into
 mysql_result() or mysql_fetch_array() or mysql_fetch_row()

 Read the manual for the differences -- including examples.


 You say:
 J rest of us we rely on examples, etc to get it done.

 They ARE in the manual, which is pretty much the best manual out there
 for just about anything.

 Good luck,
 - Julie

 -- Julie Meloni
 -- [EMAIL PROTECTED]
 -- www.thickbook.com

 Find Sams Teach Yourself MySQL in 24 Hours at
 http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20




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




Re: Re[2]: [PHP-DB] how to pull array out?

2002-05-30 Thread Jason Wong

On Friday 31 May 2002 02:17, Jas wrote:
 Ok, given there are people out there that expect people to do the work for
 them, however if you look at my original post (today) you will see that I
 have queried the database, feed the results into an array, then called the
 array elements into my form, however simple this may be for you it is still
 not pulling out the results of the array into my form.  I do believe I am
 missing something, and doing homework is a part of my everyday routine
 trying to develop web based apps.  The code again:

 $table = auth_users; // names the table to query correct?
  $record = mysql_query(SELECT * FROM $table WHERE user_id =
 '$user_id',$dbh); // pulls all records in relation to $user_id correct?
while ($row = mysql_fetch_array($record)) { // pulls results of query
 into an array correct?
 $user_id = $row['user_id']; // assigns unique names for my different
 editable regions correct?
 $f_name = $row['f_name'];
 $l_name = $row['l_name'];
 $email_addy = $row['email_addy'];
 $un = $row['un'];
 $pw = $row['pw']; }

1) Check that the stuff you're getting from the query is correct by making 
liberal use of echo() eg echo(f_name is $f_name) etc.

 $var_form .= form name=\$user_id\ method=\post\
 action=\del_account.php\

2) You seem to be missing an opening double-quote:

  $var_form .= form name=\$user_id\ method=\post\

 Any help or examples are appreciated.  Please understand I am trying to
 learn this scripting language and RTFM does not help as most of the time I
 post here as a LAST resort, i.e. after I have indeed RTFM'ed.

The trick is to start with something simple then build upon it. Don't try to 
write your complete program in one go, build it up step by step.

For example if I was writing the above stuff I would have split it into at 
least 2 steps.

1) Connect to db and make query. Verify that query gives expected results.
2) Incorporate the results of query into the form.

One last tip: do try to make your db connection code like it is done in the 
manual -- ie incorporate some error handling. You'll save yourself a lot of 
grief in the long run.

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


/*
You are deeply attached to your friends and acquaintances.
*/


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




RE: Re[2]: [PHP-DB] how to pull array out?

2002-05-30 Thread Ed Gorski

People use to suppress errors / warning messagesI know I use it a lot 
with obdc and SQL SERVER procedures...

ed

At 02:32 PM 5/30/2002 -0400, Leotta, Natalie (NCI/IMS) wrote:
 From what I've seen on the PHP.net site, it doesn't look like people use the
@ in @mysql_query, and I know that I don't use it for sybase_query.  Where
did it come from?

Assuming that's not the problem, I'd try printing out everything.  Right
after your while, print $row - it should say array, then try printing
$row[0] and see if that works.  Then try printing $row['user_id'].

You may also want to try doing a SELECT with the fieldnames, instead of just
the *.  Also, make sure you're typing the field names correctly - they are
case sensitive.

Hopefully one of these suggestions will help you.

-Natalie

-Original Message-
From: Jas [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 30, 2002 2:18 PM
To: [EMAIL PROTECTED]
Subject: Re: Re[2]: [PHP-DB] how to pull array out?


Ok, given there are people out there that expect people to do the work for
them, however if you look at my original post (today) you will see that I
have queried the database, feed the results into an array, then called the
array elements into my form, however simple this may be for you it is still
not pulling out the results of the array into my form.  I do believe I am
missing something, and doing homework is a part of my everyday routine
trying to develop web based apps.  The code again:

$table = auth_users; // names the table to query correct?
  $record = @mysql_query(SELECT * FROM $table WHERE user_id =
'$user_id',$dbh); // pulls all records in relation to $user_id correct?
while ($row = mysql_fetch_array($record)) { // pulls results of query
into an array correct?
 $user_id = $row['user_id']; // assigns unique names for my different
editable regions correct?
 $f_name = $row['f_name'];
 $l_name = $row['l_name'];
 $email_addy = $row['email_addy'];
 $un = $row['un'];
 $pw = $row['pw']; }
 $var_form .= form name=\$user_id\ method=\post\
action=\del_account.php\
   bEdit Account $user_id/bbr // echoes the $user_id that is going
to be edited correct?
 First Name:input type=\text\ name=\f_name\ size=\30\
maxlength=\30\ value=\$f_name\br // displays text box to edit with
$f_name variable from resulting array correct?
 Last Name:input type=\text\ name=\l_name\ size=\30\
maxlength=\30\ value=\$l_name\br // displays text box to edit with
$l_name variable from resulting array correct?
 Email:input type=\text\ name=\email_addy\ size=\30\
maxlength=\30\ value=\$email_addy\br // displays text box to edit
with $email_addy variable from resulting array correct?
 User Name:input type=\text\ name=\un\ size=\30\ maxlength=\30\
value=\$un\br  // displays text box to edit with $un variable from
resulting array correct?
 Password:input type=\password\ name=\pw\ size=\30\
maxlength=\30\br // displays text box to edit with $pw variable from
resulting array correct?
 Confirm Password:input type=\password\ name=\cpw\ size=\30\
maxlength=\30\
 nbsp;input type=\submit\ name=\add\ value=\edit
user\nbsp;nbsp;input type=\reset\ name=\reset\ value=\reset\;

Any help or examples are appreciated.  Please understand I am trying to
learn this scripting language and RTFM does not help as most of the time I
post here as a LAST resort, i.e. after I have indeed RTFM'ed.
Thanks again,
Jas


Julie Meloni [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Jas (and anyone else) -
 
  With all due respect, you're acting like a troll.  Posting a question,
  getting MANY correct answers, then reposting the question and bitching
  about not understanding the answers, well, that's troll-like.
 
  Granted, many responses on this list over the past while have been
  sarcastic, but usually also have the answer in them.  The tone comes
  from people asking the questions not doing their own homework.
 
  e.g. http://www.tuxedo.org/~esr/faqs/smart-questions.html
 
  Mailing lists such as this one are not intended to give people
  verbatim answers to their problems, such as I have to write an
  application for my university class, please do it for me and the
  like.  Instead, these lists will help those who attempt to help
  themselves.
 
  The fact of the matter is, RTFM is the right answer.  The very
  simplistic method of reading the results of a MySQL query are right
  there in the manual, in the MySQL query functions section.  Also,
  they're in zillions of tutorials, any basic book on PHP, and so on.
 
  In short:
 
  1) connect to db server -- mysql_connect()
  2) select db -- mysql_select_db()
  3) issue query -- mysql_query()
  4) from there you get a result identifier.  You feed that into
  mysql_result() or mysql_fetch_array() or mysql_fetch_row()
 
  Read the manual for the differences -- including examples.
 
 
  You say:
  J rest of us we rely on examples, etc to get

Re: Re[2]: [PHP-DB] how to pull array out?

2002-05-30 Thread Jas

SUCCESS
Ok, I have fixed the problem.  Here is the code, I hope it helps anyone that
comes accross something like this.  Sorry for being a troll.
Jas
// Displays select form of current users in database table for editing
$table = users;
 $record = @mysql_query(SELECT * FROM $table,$dbh);
  while ($row = mysql_fetch_array($record)) {
$user_id = $row['user_id'];
$f_name = $row['f_name'];
$l_name = $row['l_name'];
$email_addy = $row['email_addy'];
$un = $row['un'];
$pw = $row['pw'];
$option .=OPTION VALUE=\$user_id\$f_name $l_name/OPTION;
$var_form = pFORM METHOD=\post\ ACTION=\edit_account.php\
bPlease select the user you would like to edit from the list/bbr
SELECT NAME=\blank\$option/SELECT
INPUT TYPE=\submit\ NAME=\submit\ VALUE=\select\
/FORMbr;
// Takes value of blank and looks for a record matching selected user and
puts the results into a form for editing
$table = auth_users;
 $record = @mysql_query(SELECT * FROM $table WHERE user_id =
'$blank',$dbh);
   while ($row = mysql_fetch_array($record)) {
$user_id = $row['user_id'];
$f_name = $row['f_name'];
$l_name = $row['l_name'];
$email_addy = $row['email_addy'];
$un = $row['un'];
$pw = $row['pw']; }
$var_form .= table width=\100%\ border=\0\ cellpadding=\7\form
name=\$user_id\ method=\post\ action=\del_account.php\
  trtd width=\20%\ colspan=\2\bEdit Account
$user_id/b/td/tr
trtd width=\20%\First Name:/tdtd width=\80%\input
type=\text\ name=\$f_name\ size=\30\ maxlength=\30\
value=\$f_name\font class=\copyright\i.e. John/font/td/tr
trtd width=\20%\Last Name:/tdtd width=\80%\input
type=\text\ name=\$l_name\ size=\30\ maxlength=\30\
value=\$l_name\font class=\copyright\i.e. Doe/font/td/tr
  trtd width=\20%\Email:/tdtd width=\80%\input
type=\text\ name=\$email_addy\ size=\30\ maxlength=\30\
value=\$email_addy\font class=\copyright\i.e.
[EMAIL PROTECTED]/font/td/tr
trtd width=\20%\User Name:/tdtd width=\80%\input
type=\text\ name=\$un\ size=\30\ maxlength=\30\ value=\$un\font
class=\copyright\i.e. j-doe/font/td/tr
trtd width=\20%\Password:/tdtd width=\80%\input
type=\password\ name=\$pw\ size=\30\ maxlength=\30\font
class=\copyright\(password must be alpha-numeric, i.e.
pAs5w0rd)/font/td/tr
trtd width=\20%\Confirm Password:/tdtd
width=\80%\input type=\password\ name=\$pw\ size=\30\
maxlength=\30\font class=\copyright\please confirm password
entered/font/td/tr
trtd width=\20%\nbsp;/tdtd width=\80%\input
type=\submit\ name=\add\ value=\edit user\nbsp;nbsp;input
type=\reset\ name=\reset\ value=\reset\/td/tr
   /form/table;
*** The problem was that I was looking for the variable $user_id in my
select statement not the option name which is blank (just me getting ahead
of myself, sorry once again) ***

Natalie Leotta [EMAIL PROTECTED] wrote in message
7546CB15C0A1D311BF0D0004AC4C4B0C024AC468@SSIMSEXCHNG">news:7546CB15C0A1D311BF0D0004AC4C4B0C024AC468@SSIMSEXCHNG...
 From what I've seen on the PHP.net site, it doesn't look like people use
the
 @ in @mysql_query, and I know that I don't use it for sybase_query.  Where
 did it come from?

 Assuming that's not the problem, I'd try printing out everything.  Right
 after your while, print $row - it should say array, then try printing
 $row[0] and see if that works.  Then try printing $row['user_id'].

 You may also want to try doing a SELECT with the fieldnames, instead of
just
 the *.  Also, make sure you're typing the field names correctly - they are
 case sensitive.

 Hopefully one of these suggestions will help you.

 -Natalie

 -Original Message-
 From: Jas [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, May 30, 2002 2:18 PM
 To: [EMAIL PROTECTED]
 Subject: Re: Re[2]: [PHP-DB] how to pull array out?


 Ok, given there are people out there that expect people to do the work
for
 them, however if you look at my original post (today) you will see that I
 have queried the database, feed the results into an array, then called the
 array elements into my form, however simple this may be for you it is
still
 not pulling out the results of the array into my form.  I do believe I am
 missing something, and doing homework is a part of my everyday routine
 trying to develop web based apps.  The code again:

 $table = auth_users; // names the table to query correct?
  $record = @mysql_query(SELECT * FROM $table WHERE user_id =
 '$user_id',$dbh); // pulls all records in relation to $user_id correct?
while ($row = mysql_fetch_array($record)) { // pulls results of query
 into an array correct?
 $user_id = $row['user_id']; // assigns unique names for my different
 editable regions correct?
 $f_name = $row['f_name'];
 $l_name = $row['l_name'];
 $email_addy = $row['email_addy'];
 $un = $row['un'];
 $pw = $row['pw']; }
 $var_form .= form name=\$user_id\ method=\post\
 action=\del_account.php\
   bEdit Account $user_id/bbr // echoes the