[PHP] Forms Question: Options

2004-12-11 Thread Steve Marquez
Hi everyone!

Can someone help me with this question?

I created a photo upload utility with individual galleries that images can
be uploaded into. In the MySQL database, there are multiple names of
galleries, some are the same. I want to have a select menu to show just the
unique names of the galleries.

I have used:

Select DISTINCT gallery_names from images_upload;

I have about 15 records, ten are GALLERY1 and 5 are GALLERY2. When I use
the DISTINCT, two are output. It works perfectly in the MySQL terminal.

However, when I use the same in PHP as a web page, it only outputs one, the
one with only 5 records.

Here is the code:

?php 

// log into our local server using the MySQL root user.
   $dbh = mysql_connect( hostname, username, password );

   // select the database.
   mysql_select_db( db ) or die ( mysql_error() . \n );

   //and read it back for printing purposes.
   $get_table_data = SELECT DISTINCT gallery_name FROM images_upload ORDER
BY gallery_name DESC;
   
   $response = mysql_query( $get_table_data, $dbh );

   //now print it out for the user.
   if ( $one_line_of_data = mysql_fetch_array( $response ) ) {
 extract ( $one_line_of_data );
 }

 ?


-- Snip --


  ?php
  
   while ( $data = mysql_fetch_array( $response, MYSQL_ASSOC)) {
 print select name=\gallery_name\;
 foreach ( $data as $option_value ) {
 print option
value=\$option_value\$option_value/option;
  
 }  print /select;
   }
  
  ?


-- Snip --

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


[PHP] forms question -- simple

2003-06-13 Thread Gregory Landry
Hi all,

I'm new to the list and to PHP. I haven't bought a book as of yet but I've
found a number of resources that are getting me through the basics.

I am collecting data from a form. I've having no problems collecting the
data and printing it out.  But...

I have a form with check boxes with 4 options. See below.


input type=checkbox value=Investment name=investment
input type=checkbox value=Vacation Home  name=vacation
input type=checkbox value=Retirement Home  name=retirement
input type=checkbox value=Primary Home  name=primary



This form data is being sent off to a php page to get the values printed
out. See below:


**

print Which best describes your reason for wanting to purchase land?br;
print $investmentbr $investment2br $investment3br $investment4br; 


**

The problem is if a check box is not checked a blank space gets printed out
which I don't want. Can someone show me how to use an if then statement
with the following stucture:

***
if $investment not eqaul to a blank then print $investment
***

I would use this structure for each of the variables in the checkboxes
above. I'm sure this could be done with arrays in some form or another but
since I'm new at this I would just as soon keep it simple for now and learn
more sophisticated techniques later.

Thanks so much,

Greg Landry
[EMAIL PROTECTED]



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



RE: [PHP] forms question -- simple

2003-06-13 Thread gregory landry
I figured it out. Yipppee..

Thanks 

-Original Message-
From: Gregory Landry [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 13, 2003 4:10 PM
To: [EMAIL PROTECTED]
Subject: [PHP] forms question -- simple


Hi all,

I'm new to the list and to PHP. I haven't bought a book as of yet but I've
found a number of resources that are getting me through the basics.

I am collecting data from a form. I've having no problems collecting the
data and printing it out.  But...

I have a form with check boxes with 4 options. See below.


input type=checkbox value=Investment name=investment
input type=checkbox value=Vacation Home  name=vacation
input type=checkbox value=Retirement Home  name=retirement input
type=checkbox value=Primary Home  name=primary



This form data is being sent off to a php page to get the values printed
out. See below:


**

print Which best describes your reason for wanting to purchase land?br;
print $investmentbr $investment2br $investment3br $investment4br; 


**

The problem is if a check box is not checked a blank space gets printed out
which I don't want. Can someone show me how to use an if then statement with
the following stucture:

***
if $investment not eqaul to a blank then print $investment
***

I would use this structure for each of the variables in the checkboxes
above. I'm sure this could be done with arrays in some form or another but
since I'm new at this I would just as soon keep it simple for now and learn
more sophisticated techniques later.

Thanks so much,

Greg Landry
[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



[PHP] Forms Question

2003-02-15 Thread Beauford.2002
Hi,

Im trying to figure out the best way to do the following.  I need to have a
series of forms that when the user finishes the first part of the form he is
sent to another page where a second form is filled out, and then a third.
Making the forms etc. is no problem, what I'm not sure of is how to keep the
data from all forms so it can be displayed at the end. I don't want to have
anything written to the users drive, or to the server - so this information
would have to be kept in memory. Would an array work in this situation?

Any ideas are appreciated.

TIA



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




RE: [PHP] Forms Question

2003-02-15 Thread Chris McCluskey
Hey there,
 
Maintaining state in a web application is always a difficult thing.. fortunatly, you 
use PHP, which makes it a bit easier.  However, if you do not want anything written to 
the server or to the user's drive you are out of luck, simply because at very least 
you will need to have the user download your HTML which will be written to the hard 
drive for caching.  There are a few ways of doing making this work:
 
1)  Store the form values from the previous form stored in hidden form fields on each 
page of the form, such as the fields the user filled out on form1 will be stored as 
hidden form fields on form2, the fields from form1 and form2 will be stored in hidden 
fields on form3, etc..  This is not the cleanest way, but as far as crossplatforming 
goes, it's one of the best.
 
2)  Use a cookie to store the form fields.  YUCK!  Cookies have many good 
applications, but they are usually disabled on the user's browser as they have been 
miss used in the past.  of course, this goes against your rule of keeping things from 
being written on the user's harddrive.
 
3)  Finally, you could use sessions.  The cleanest way i would think to pass variables 
from one form to another is to create an object in PHP that contains the fields in the 
form as variables.  Pass that object from form to form, adding the information the 
application recieves from the user into the object at each form submit.  That way, all 
you have to do is to pass the sessionid from page to page.  How do you do that you 
ask?  2 ways:  1) you could save it in a cookie (this is the default way of passing 
sessionids in PHP), 2) OR you can use a really cool thing PHP does and turn 
URL-rewriting on in the php.ini file.  This will automatically rewrite all the urls 
you have on your page to append the ?SESSIONID=id at the end and include the 
sessionid as a hidden form field on all your pages.  Cool, huh?  yeah.. PHP kicks ass. 
 =)
 
If you need more help on how to do this, don't hesitate to ask.
 
good luck!
-Chris

-Original Message- 
From: Beauford.2002 [mailto:[EMAIL PROTECTED]] 
Sent: Sat 2/15/2003 10:02 AM 
To: PHP General 
Cc: 
Subject: [PHP] Forms Question



Hi,

Im trying to figure out the best way to do the following.  I need to have a
series of forms that when the user finishes the first part of the form he is
sent to another page where a second form is filled out, and then a third.
Making the forms etc. is no problem, what I'm not sure of is how to keep the
data from all forms so it can be displayed at the end. I don't want to have
anything written to the users drive, or to the server - so this information
would have to be kept in memory. Would an array work in this situation?

Any ideas are appreciated.

TIA



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






Re: [PHP] Forms Question

2003-02-15 Thread Beauford.2002
Yep, Definitely need help. I tried option 1, but for some reason the
variables are not being passed - and this is messy and not really one I want
to use. Option 3 sounds like the cleanest, but I am not 100% familiar with
sessions - I have used this on another page with a counter so the counter
doesn't get run up on every refresh, and I am sure this is similar, but I
would need some further help on how to pass the information from one page to
the next.

Any help is appreciated..

- Original Message -
From: Chris McCluskey [EMAIL PROTECTED]
To: Beauford.2002 [EMAIL PROTECTED]; PHP General
[EMAIL PROTECTED]
Sent: Saturday, February 15, 2003 1:25 PM
Subject: RE: [PHP] Forms Question


 Hey there,

 Maintaining state in a web application is always a difficult thing..
fortunatly, you use PHP, which makes it a bit easier.  However, if you do
not want anything written to the server or to the user's drive you are out
of luck, simply because at very least you will need to have the user
download your HTML which will be written to the hard drive for caching.
There are a few ways of doing making this work:

 1)  Store the form values from the previous form stored in hidden form
fields on each page of the form, such as the fields the user filled out on
form1 will be stored as hidden form fields on form2, the fields from form1
and form2 will be stored in hidden fields on form3, etc..  This is not the
cleanest way, but as far as crossplatforming goes, it's one of the best.

 2)  Use a cookie to store the form fields.  YUCK!  Cookies have many good
applications, but they are usually disabled on the user's browser as they
have been miss used in the past.  of course, this goes against your rule of
keeping things from being written on the user's harddrive.

 3)  Finally, you could use sessions.  The cleanest way i would think to
pass variables from one form to another is to create an object in PHP that
contains the fields in the form as variables.  Pass that object from form to
form, adding the information the application recieves from the user into the
object at each form submit.  That way, all you have to do is to pass the
sessionid from page to page.  How do you do that you ask?  2 ways:  1) you
could save it in a cookie (this is the default way of passing sessionids in
PHP), 2) OR you can use a really cool thing PHP does and turn URL-rewriting
on in the php.ini file.  This will automatically rewrite all the urls you
have on your page to append the ?SESSIONID=id at the end and include the
sessionid as a hidden form field on all your pages.  Cool, huh?  yeah.. PHP
kicks ass.  =)

 If you need more help on how to do this, don't hesitate to ask.

 good luck!
 -Chris

 -Original Message-
 From: Beauford.2002 [mailto:[EMAIL PROTECTED]]
 Sent: Sat 2/15/2003 10:02 AM
 To: PHP General
 Cc:
 Subject: [PHP] Forms Question



 Hi,

 Im trying to figure out the best way to do the following.  I need to have
a
 series of forms that when the user finishes the first part of the form he
is
 sent to another page where a second form is filled out, and then a third.
 Making the forms etc. is no problem, what I'm not sure of is how to keep
the
 data from all forms so it can be displayed at the end. I don't want to
have
 anything written to the users drive, or to the server - so this
information
 would have to be kept in memory. Would an array work in this situation?

 Any ideas are appreciated.

 TIA



 --
 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




[PHP] forms question

2002-06-25 Thread M.E. Suliman

Hi

I'm busy with an order form in php.  How would I display a text field only
if a checkbox is checked.  The reason for this is that if the user selects
the product in the form and, how would I get to display the quantity field
corresponding to that checkbox

Any help would be appreciated.

Thanks

Mohamed


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




Re: [PHP] forms question

2002-06-25 Thread Evan Nemerson

If you want to do it from PHP, then the forms will have to be seperate (PHP is 
server side...) You assign a value to a checkbox, then in the page you submit 
to, use something like

if ( $_POST[$checkbox_name] == checked_value )
{
...
}


On Tuesday 25 June 2002 10:30 am, M.E. Suliman wrote:
 Hi

 I'm busy with an order form in php.  How would I display a text field only
 if a checkbox is checked.  The reason for this is that if the user selects
 the product in the form and, how would I get to display the quantity field
 corresponding to that checkbox

 Any help would be appreciated.

 Thanks

 Mohamed

-- 
To Believe without evidence and demonstration is an act of ignorance and 
folly.

Volney


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




Re: [PHP] forms question

2002-06-25 Thread 1LT John W. Holmes

 I'm busy with an order form in php.  How would I display a text field only
 if a checkbox is checked.  The reason for this is that if the user selects
 the product in the form and, how would I get to display the quantity field
 corresponding to that checkbox

if(isset($_REQUEST['checkbox_name']))
{ echo textareaData/textarea; }

etc...

Adapt to your needs. remember that PHP runs on the server, so what you want
to happen won't work unless the form is submitted in between. i.e. check the
checkbox, submit the form, now it shows/doesn't show a text area depending
on the whether the checkbox was checked or not.

---John Holmes...


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




RE: [PHP] forms question

2002-06-25 Thread Lazor, Ed

I do what you're asking with Javascript.  Lookup dynamic forms and you'll
find a lot of examples.

On Tuesday 25 June 2002 10:30 am, M.E. Suliman wrote:
 I'm busy with an order form in php.  How would I display a text field only
 if a checkbox is checked.  The reason for this is that if the user selects
 the product in the form and, how would I get to display the quantity field
 corresponding to that checkbox
 

This message is intended for the sole use of the individual and entity to
whom it is addressed, and may contain information that is privileged,
confidential and exempt from disclosure under applicable law.  If you are
not the intended addressee, nor authorized to receive for the intended
addressee, you are hereby notified that you may not use, copy, disclose or
distribute to anyone the message or any information contained in the
message.  If you have received this message in error, please immediately
advise the sender by reply email and delete the message.  Thank you very
much.   

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




Re: [PHP] forms question

2002-06-25 Thread Evan Nemerson

That would be the best idea, but he *is* asking on a PHP list... That's why i 
reminded him that PHP is server-side.


On Tuesday 25 June 2002 13:02 pm, Lazor, Ed wrote:
 I do what you're asking with Javascript.  Lookup dynamic forms and you'll
 find a lot of examples.

 On Tuesday 25 June 2002 10:30 am, M.E. Suliman wrote:
  I'm busy with an order form in php.  How would I display a text field
  only if a checkbox is checked.  The reason for this is that if the user
  selects the product in the form and, how would I get to display the
  quantity field corresponding to that checkbox

 ***
* This message is intended for the sole use of the individual and entity to
 whom it is addressed, and may contain information that is privileged,
 confidential and exempt from disclosure under applicable law.  If you are
 not the intended addressee, nor authorized to receive for the intended
 addressee, you are hereby notified that you may not use, copy, disclose or
 distribute to anyone the message or any information contained in the
 message.  If you have received this message in error, please immediately
 advise the sender by reply email and delete the message.  Thank you very
 much.

-- 
God is a comedian playing to an audience too afraid to laugh.

Voltaire


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