Re: [PHP] Populate Popup Menu from Database

2002-07-01 Thread Mike Tuller

Thanks for the tip.

> From: Erik Price <[EMAIL PROTECTED]>
> Date: Mon, 1 Jul 2002 17:05:39 -0400
> To: Mike Tuller <[EMAIL PROTECTED]>
> Cc: php mailing list <[EMAIL PROTECTED]>
> Subject: Re: [PHP] Populate Popup Menu from Database
> 
> 
> On Monday, July 1, 2002, at 04:22  PM, Mike Tuller wrote:
> 
>> Thanks. Here is what I did for future reference.
> 
> Good.  What you chose to do is exactly what I do except for one
> thing... :
> 
>> $sql = "select department_name from Departments";
> 
> I generally grab the primary key column value as well, in the same
> query, and then I use that as the "value" attribute for the 
> tags:
> 
>> while($row = mysql_fetch_array($sql_result))
>> {
>> $department = $row["department_name"];
>> echo "$department";
>> 
>> }
> 
> while ($row = mysql_fetch_assoc($result)) {
> $dept_id = $row['department_id'];
> $dept_name = $row['department_name'];
> echo "$department_name\n";
> }
> 
> The reason I do this is because I end up using the ID far more than the
> "name" of a database record -- while I might echo the "name" to the user
> where needed (such as in the above dropdown listbox), the ID comes in
> handy as a reference in hyperlinks, form fields, etc -- it provides
> something that I've discovered is really missing in writing HTML-based
> applications: a unique handle on an object.  This is very hard to
> replicate given the statelessness of HTTP, but with a database record's
> primary key, you always have this unique identifier by which to refer to
> the object.  and a number is more pithy than a name.
> 
> It'll avoid situations where someone enters the same "name" value twice,
> too.  But it's not really a big deal unless you're doing a lot of work
> with a lot of data.
> 
> 
> Erik
> 
> 
> 
> 
> 
> Erik Price
> Web Developer Temp
> Media Lab, H.H. Brown
> [EMAIL PROTECTED]
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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




Re: [PHP] Populate Popup Menu from Database

2002-07-01 Thread Erik Price


On Monday, July 1, 2002, at 04:22  PM, Mike Tuller wrote:

> Thanks. Here is what I did for future reference.

Good.  What you chose to do is exactly what I do except for one 
thing... :

> $sql = "select department_name from Departments";

I generally grab the primary key column value as well, in the same 
query, and then I use that as the "value" attribute for the  
tags:

> while($row = mysql_fetch_array($sql_result))
> {
> $department = $row["department_name"];
> echo "$department";
>
> }

while ($row = mysql_fetch_assoc($result)) {
$dept_id = $row['department_id'];
$dept_name = $row['department_name'];
echo "$department_name\n";
}

The reason I do this is because I end up using the ID far more than the 
"name" of a database record -- while I might echo the "name" to the user 
where needed (such as in the above dropdown listbox), the ID comes in 
handy as a reference in hyperlinks, form fields, etc -- it provides 
something that I've discovered is really missing in writing HTML-based 
applications: a unique handle on an object.  This is very hard to 
replicate given the statelessness of HTTP, but with a database record's 
primary key, you always have this unique identifier by which to refer to 
the object.  and a number is more pithy than a name.

It'll avoid situations where someone enters the same "name" value twice, 
too.  But it's not really a big deal unless you're doing a lot of work 
with a lot of data.


Erik





Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


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




Re: [PHP] Populate Popup Menu from Database

2002-07-01 Thread Mike Tuller

Thanks. Here is what I did for future reference.


 -- Select a Department -- 

$department";

}
?>





> From: Erik Price <[EMAIL PROTECTED]>
> Date: Mon, 1 Jul 2002 09:18:12 -0400
> To: Mike Tuller <[EMAIL PROTECTED]>
> Cc: php mailing list <[EMAIL PROTECTED]>
> Subject: Re: [PHP] Populate Popup Menu from Database
> 
> 
> On Saturday, June 29, 2002, at 11:41  AM, Mike Tuller wrote:
> 
>> What is here is beyond my understanding, and seems like it is a little
>> much
>> for what I need.
>> 
>> Here is what my database table looks like:
>> 
>> Departments
>> department_id
>> department_name
>> 
>> I just want to list the department name in the popup.
> 
> although I wrote this instruction in response to a question about
> integrating the listbox with javaScript, ignore the JS stuff, and you
> will see how to dynamically populate a listbox with database data:
> 
> http://marc.theaimsgroup.com/?l=php-general&m=102503848224300&w=2
> 
> 
> 
> 
> 
> Erik Price
> Web Developer Temp
> Media Lab, H.H. Brown
> [EMAIL PROTECTED]
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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




Re: [PHP] Populate Popup Menu from Database

2002-07-01 Thread Erik Price


On Saturday, June 29, 2002, at 11:41  AM, Mike Tuller wrote:

> What is here is beyond my understanding, and seems like it is a little 
> much
> for what I need.
>
> Here is what my database table looks like:
>
> Departments
> department_id
> department_name
>
> I just want to list the department name in the popup.

although I wrote this instruction in response to a question about 
integrating the listbox with javaScript, ignore the JS stuff, and you 
will see how to dynamically populate a listbox with database data:

http://marc.theaimsgroup.com/?l=php-general&m=102503848224300&w=2





Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


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




Re: [PHP] Populate Popup Menu from Database

2002-06-30 Thread Jason Wong

On Sunday 30 June 2002 03:03, Mike Tuller wrote:
> To let everyone know, I did apologize to Mr. Wong. I misunderstood what he
> was trying to ask me. I took it as he was saying "It's easy, what is "your"
> problem" rather than "What "is" your problem" .

Thanks. But no need to call me "Mr" though :)

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

/*
Yevtushenko has... an ego that can crack crystal at a distance of twenty feet.
-- John Cheever
*/


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




Re: [PHP] Populate Popup Menu from Database

2002-06-29 Thread Mike Tuller

To let everyone know, I did apologize to Mr. Wong. I misunderstood what he
was trying to ask me. I took it as he was saying "It's easy, what is "your"
problem" rather than "What "is" your problem" .

> From: Chris Shiflett <[EMAIL PROTECTED]>
> Date: Sat, 29 Jun 2002 13:50:14 -0500
> To: Mike Tuller <[EMAIL PROTECTED]>
> Cc: php mailing list <[EMAIL PROTECTED]>, Jason Wong
> <[EMAIL PROTECTED]>
> Subject: Re: [PHP] Populate Popup Menu from Database
> 
> Mike Tuller wrote:
> 
>> I only ask questions if I have tried to do something myself already. I am
>> not looking for someone to do something for me. When I do ask a question
>> though, I feel I deserve at least a little respect. If you want to be an
>> ass, do it somewhere else.
>> 
> It seems *you* are the one being an ass and needing to "do it somewhere
> else."
> 
> If you can't have enough respect for people trying to help you by
> answering the simplest of questions (that should have been given in your
> original question anyway), you don't deserve an answer.
> 
> Here are Mr. Wong's questions again (very appropriate questions at
> that). Perhaps if you offer him a sincere apology, thank him for his
> time, and *answer* *his* *questions*, he might be willing to forgive
> your poor attitude and offer you some help.
> 
>>> There are two things you need to know:
>>> 
>>> 1) How to construct a select list in HTML
>>> 2) How to retrieve the info from the db
>>> 
>>> What are you having problems with?
>>> 
> If you don't know a damn thing, that's fine. An appropriate answer would
> be, "I neither know how to construct a select list in HTML nor how to
> retrieve information from a database."
> 
> Chris
> 


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




Re: [PHP] Populate Popup Menu from Database

2002-06-29 Thread Chris Shiflett

Mike Tuller wrote:

>I only ask questions if I have tried to do something myself already. I am
>not looking for someone to do something for me. When I do ask a question
>though, I feel I deserve at least a little respect. If you want to be an
>ass, do it somewhere else.
>
It seems *you* are the one being an ass and needing to "do it somewhere 
else."

If you can't have enough respect for people trying to help you by 
answering the simplest of questions (that should have been given in your 
original question anyway), you don't deserve an answer.

Here are Mr. Wong's questions again (very appropriate questions at 
that). Perhaps if you offer him a sincere apology, thank him for his 
time, and *answer* *his* *questions*, he might be willing to forgive 
your poor attitude and offer you some help.

>>There are two things you need to know:
>>
>>1) How to construct a select list in HTML
>>2) How to retrieve the info from the db
>>
>>What are you having problems with?
>>
If you don't know a damn thing, that's fine. An appropriate answer would 
be, "I neither know how to construct a select list in HTML nor how to 
retrieve information from a database."

Chris


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




Re: [PHP] Populate Popup Menu from Database

2002-06-29 Thread Jason Wong

On Sunday 30 June 2002 00:31, Mike Tuller wrote:
> I only ask questions if I have tried to do something myself already. I am
> not looking for someone to do something for me. When I do ask a question
> though, I feel I deserve at least a little respect. If you want to be an
> ass, do it somewhere else.

Attitude! What part of my post offended you? I was merely stating what you 
need to know to be able to solve your problem. And then I asked which part 
you were having trouble with.

You have given no indication in your post as to what level of competence you 
have in PHP and HTML. The only hint was that the example you quoted was 
beyond your understanding.

You have given no indication of what you have done and did or didn't work.

So how is one supposed to respond to your post?

a) give you a solution, which may or may not be beyond your understanding?
b) or prod you along the right direction with a request for more information?

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

/*
The world is coming to an end--save your buffers!
*/


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




Re: [PHP] Populate Popup Menu from Database

2002-06-29 Thread Mike Tuller

I only ask questions if I have tried to do something myself already. I am
not looking for someone to do something for me. When I do ask a question
though, I feel I deserve at least a little respect. If you want to be an
ass, do it somewhere else.

> From: Jason Wong <[EMAIL PROTECTED]>
> Organization: Gremlins Associates
> Reply-To: [EMAIL PROTECTED]
> Date: Sat, 29 Jun 2002 23:54:22 +0800
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Populate Popup Menu from Database
> 
> On Saturday 29 June 2002 23:41, Mike Tuller wrote:
>> I have some popup menus and want the items in the menu to be populated from
>> a database. In this case I have a table that contains a listing of
>> departments. I have a page that I can go in and add/delete departments, and
>> want the changes to reflect in the menu the next time you go to the page.
>> 
>> I searched for examples and found this:
>> 
>> http://marc.theaimsgroup.com/?l=php-general&m=97628169623096&w=2
>> 
>> What is here is beyond my understanding, and seems like it is a little much
>> for what I need.
>> 
>> Here is what my database table looks like:
>> 
>> Departments
>> department_id
>> department_name
>> 
>> I just want to list the department name in the popup.
> 
> There are two things you need to know:
> 
> 1) How to construct a select list in HTML
> 2) How to retrieve the info from the db
> 
> What are you having problems with?
> 
> -- 
> Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
> 
> /*
> The only rose without thorns is friendship.
> */
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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




Re: [PHP] Populate Popup Menu from Database

2002-06-29 Thread Mike Tuller

Thanks. I thought the example I found was a little to complicated for
something like this.


> From: "Cal Evans" <[EMAIL PROTECTED]>
> Date: Sat, 29 Jun 2002 11:03:16 -0500
> To: "Mike Tuller" <[EMAIL PROTECTED]>, "php mailing list"
> <[EMAIL PROTECTED]>
> Subject: RE: [PHP] Populate Popup Menu from Database
> 
> Hi Mike,
> 
> Check out ADODB. It's a database abstraction layer for PHP that has
> functions to do this. (php.weblogs.com)  Otherwise it's kinda easy to do
> this, here's some psuedo-code that shoudl get you going.
> 
>  // Make your connection to your database
> // Select * from department
> ?>
> 
>  //While !EOF
> ?>
>   $rs->fields['departmentName']; ?>
> ?>
>  // loop
> ?>
> 
> 
> =C=
> 
> *
> * Cal Evans
> * Journeyman Programmer
> * Techno-Mage
> * http://www.calevans.com
> *
> 
> 
> -Original Message-
> From: Mike Tuller [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, June 29, 2002 10:42 AM
> To: php mailing list
> Subject: [PHP] Populate Popup Menu from Database
> 
> 
> I have some popup menus and want the items in the menu to be populated from
> a database. In this case I have a table that contains a listing of
> departments. I have a page that I can go in and add/delete departments, and
> want the changes to reflect in the menu the next time you go to the page.
> 
> I searched for examples and found this:
> 
> http://marc.theaimsgroup.com/?l=php-general&m=97628169623096&w=2
> 
> What is here is beyond my understanding, and seems like it is a little much
> for what I need.
> 
> Here is what my database table looks like:
> 
> Departments
>   department_id
>   department_name
> 
> I just want to list the department name in the popup.
> 
> 
> Thanks,
> Mike
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


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




RE: [PHP] Populate Popup Menu from Database

2002-06-29 Thread Cal Evans

Hi Mike,

Check out ADODB. It's a database abstraction layer for PHP that has
functions to do this. (php.weblogs.com)  Otherwise it's kinda easy to do
this, here's some psuedo-code that shoudl get you going.




fields['departmentID']; ?>">fields['departmentName']; ?>
?>



=C=

*
* Cal Evans
* Journeyman Programmer
* Techno-Mage
* http://www.calevans.com
*


-Original Message-
From: Mike Tuller [mailto:[EMAIL PROTECTED]]
Sent: Saturday, June 29, 2002 10:42 AM
To: php mailing list
Subject: [PHP] Populate Popup Menu from Database


I have some popup menus and want the items in the menu to be populated from
a database. In this case I have a table that contains a listing of
departments. I have a page that I can go in and add/delete departments, and
want the changes to reflect in the menu the next time you go to the page.

I searched for examples and found this:

http://marc.theaimsgroup.com/?l=php-general&m=97628169623096&w=2

What is here is beyond my understanding, and seems like it is a little much
for what I need.

Here is what my database table looks like:

Departments
department_id
department_name

I just want to list the department name in the popup.


Thanks,
Mike


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



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




Re: [PHP] Populate Popup Menu from Database

2002-06-29 Thread Jason Wong

On Saturday 29 June 2002 23:41, Mike Tuller wrote:
> I have some popup menus and want the items in the menu to be populated from
> a database. In this case I have a table that contains a listing of
> departments. I have a page that I can go in and add/delete departments, and
> want the changes to reflect in the menu the next time you go to the page.
>
> I searched for examples and found this:
>
> http://marc.theaimsgroup.com/?l=php-general&m=97628169623096&w=2
>
> What is here is beyond my understanding, and seems like it is a little much
> for what I need.
>
> Here is what my database table looks like:
>
> Departments
> department_id
> department_name
>
> I just want to list the department name in the popup.

There are two things you need to know:

1) How to construct a select list in HTML
2) How to retrieve the info from the db

What are you having problems with? 

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

/*
The only rose without thorns is friendship.
*/


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




[PHP] Populate Popup Menu from Database

2002-06-29 Thread Mike Tuller

I have some popup menus and want the items in the menu to be populated from
a database. In this case I have a table that contains a listing of
departments. I have a page that I can go in and add/delete departments, and
want the changes to reflect in the menu the next time you go to the page.

I searched for examples and found this:

http://marc.theaimsgroup.com/?l=php-general&m=97628169623096&w=2

What is here is beyond my understanding, and seems like it is a little much
for what I need.

Here is what my database table looks like:

Departments
department_id
department_name

I just want to list the department name in the popup.


Thanks,
Mike


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