 |
|
 |
|
Next: cast a long to integer?
|
| Author |
Message |
External

Since: Jun 14, 2004 Posts: 14
|
(Msg. 1) Posted: Thu Oct 18, 2007 10:04 am
Post subject: $_SERVER['PHP_SELF'] Question Archived from groups: comp>lang>php (more info?)
|
|
|
I am attempting to use the below Select Form Element to allow users to
change the category of data being viewed in a subsequent SQL statement. My
problem is, from where I am at, what is my next step to be able to do an "if
then else" loop based upon what is selected from this form element???
TIA
Kye.
<?php
$category = "SELECT * FROM `links_categories` ORDER BY category ASC LIMIT
0 , 30" or die('Error, query failed');
$catlist = mysql_query($category) or die('Error, query failed');
echo "<form method=\"post\" action=\"{$_SERVER['PHP_SELF']}\">";
echo '<SELECT name="dropdown">';
echo "<OPTION> - Please Select A Category - </OPTION>\n";
while ($row = mysql_fetch_array($catlist, MYSQL_NUM)){
echo "<OPTION value=$row[0]>{$row[1]}</OPTION>\n";
}
echo '</SELECT>';
echo "<INPUT type='submit' value='Go'>";
echo "</form>";
?> >> Stay informed about: $_SERVER['PHP_SELF'] Question |
|
| Back to top |
|
 |  |
External

Since: Aug 11, 2004 Posts: 1367
|
(Msg. 2) Posted: Thu Oct 18, 2007 12:55 pm
Post subject: Re: $_SERVER['PHP_SELF'] Question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Kye wrote:
> I am attempting to use the below Select Form Element to allow users to
> change the category of data being viewed in a subsequent SQL statement. My
> problem is, from where I am at, what is my next step to be able to do an "if
> then else" loop based upon what is selected from this form element???
>
> TIA
> Kye.
>
> <?php
> $category = "SELECT * FROM `links_categories` ORDER BY category ASC LIMIT
> 0 , 30" or die('Error, query failed');
> $catlist = mysql_query($category) or die('Error, query failed');
> echo "<form method=\"post\" action=\"{$_SERVER['PHP_SELF']}\">";
> echo '<SELECT name="dropdown">';
> echo "<OPTION> - Please Select A Category - </OPTION>\n";
> while ($row = mysql_fetch_array($catlist, MYSQL_NUM)){
> echo "<OPTION value=$row[0]>{$row[1]}</OPTION>\n";
> }
> echo '</SELECT>';
> echo "<INPUT type='submit' value='Go'>";
> echo "</form>";
> ?>
>
>
>
>
Have a page which takes the value in $_POST['dropdown'] and performs
another SQL query of the desired results.
It may be this page (i.e. if $_POST['dropdown'] is set, or a different
page, depending on your needs.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex DeleteThis @attglobal.net
================== >> Stay informed about: $_SERVER['PHP_SELF'] Question |
|
| Back to top |
|
 |  |
External

Since: Jun 14, 2004 Posts: 14
|
(Msg. 3) Posted: Sat Oct 20, 2007 7:09 am
Post subject: Re: $_SERVER['PHP_SELF'] Question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
> Have a page which takes the value in $_POST['dropdown'] and performs
> another SQL query of the desired results.
>
> It may be this page (i.e. if $_POST['dropdown'] is set, or a different
> page, depending on your needs.
Is it possible to make the select element of the form automatically execute
the "<INPUT type='submit' value='Go'>"; statement rather than having a
button to click on???
--
Yours Sincerely
Kye >> Stay informed about: $_SERVER['PHP_SELF'] Question |
|
| Back to top |
|
 |  |
External

Since: Nov 05, 2007 Posts: 18
|
(Msg. 4) Posted: Sat Oct 20, 2007 8:29 am
Post subject: Re: $_SERVER['PHP_SELF'] Question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In our last episode, , the
lovely and talented Kye broadcast on comp.lang.php:
>> Have a page which takes the value in $_POST['dropdown'] and performs
>> another SQL query of the desired results.
>>
>> It may be this page (i.e. if $_POST['dropdown'] is set, or a different
>> page, depending on your needs.
> Is it possible to make the select element of the form automatically execute
> the "<INPUT type='submit' value='Go'>"; statement rather than having a
> button to click on???
Again, this is an html question, having nothing to do with php. The answer
is "no, not in html." That is because html will not "do" anything. It is
markup. You can use javascript to make ENTER in some form field submit the
form, but this won't work in some browsers so if it "rather than having a
button" your site will alway be broken to people who don't have the "right"
browser, "properly" set. Google is an example of ENTER for submit AND
making a button available. Many commercial sites do use script to submit
when an option is selected --- for that they lose customers who are not
using the "right" browser and those who become frustrated by the
slipperiness of dropdwon boxes. In any case, it is all client side and php
has nothing to do with it.
--
Lars Eighner <http://larseighner.com/> <http://myspace.com/larseighner>
Countdown: 458 days to go.
What do you do when you're debranded? >> Stay informed about: $_SERVER['PHP_SELF'] Question |
|
| Back to top |
|
 |  |
External

Since: Aug 11, 2004 Posts: 1367
|
(Msg. 5) Posted: Sat Oct 20, 2007 9:22 am
Post subject: Re: $_SERVER['PHP_SELF'] Question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Kye wrote:
>> Have a page which takes the value in $_POST['dropdown'] and performs
>> another SQL query of the desired results.
>>
>> It may be this page (i.e. if $_POST['dropdown'] is set, or a different
>> page, depending on your needs.
>
> Is it possible to make the select element of the form automatically execute
> the "<INPUT type='submit' value='Go'>"; statement rather than having a
> button to click on???
>
Not in PHP. PHP is server-side. You need something client-side. Try
comp.lang.javascript.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex.DeleteThis@attglobal.net
================== >> Stay informed about: $_SERVER['PHP_SELF'] Question |
|
| Back to top |
|
 |  |
External

Since: Aug 11, 2004 Posts: 1367
|
(Msg. 6) Posted: Sat Oct 20, 2007 9:23 am
Post subject: Re: $_SERVER['PHP_SELF'] Question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Kye wrote:
>> Have a page which takes the value in $_POST['dropdown'] and performs
>> another SQL query of the desired results.
>>
>> It may be this page (i.e. if $_POST['dropdown'] is set, or a different
>> page, depending on your needs.
>
> Is it possible to make the select element of the form automatically execute
> the "<INPUT type='submit' value='Go'>"; statement rather than having a
> button to click on???
>
Or maybe I misunderstood your question. Why would you want a select
statement to press a button?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex.TakeThisOut@attglobal.net
================== >> Stay informed about: $_SERVER['PHP_SELF'] Question |
|
| Back to top |
|
 |  |
External

Since: Aug 31, 2007 Posts: 173
|
(Msg. 7) Posted: Sat Oct 20, 2007 11:38 am
Post subject: Re: $_SERVER['PHP_SELF'] Question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Kye wrote:
>> Have a page which takes the value in $_POST['dropdown'] and performs
>> another SQL query of the desired results.
>>
>> It may be this page (i.e. if $_POST['dropdown'] is set, or a different
>> page, depending on your needs.
>
> Is it possible to make the select element of the form automatically execute
> the "<INPUT type='submit' value='Go'>"; statement rather than having a
> button to click on???
>
Yes, with javascript.
However there are caveats.
If you actually do CHANGE the value displayed, then this code
<SELECT ...onchange="document.forms[0].submit()" >
will submit the form.
if there is only one <OPTION> element IN the select statement, this
doesn't work however. I have a workaround but its ugly. >> Stay informed about: $_SERVER['PHP_SELF'] Question |
|
| Back to top |
|
 |  |
External

Since: Aug 31, 2007 Posts: 173
|
(Msg. 8) Posted: Sat Oct 20, 2007 11:39 am
Post subject: Re: $_SERVER['PHP_SELF'] Question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Kye wrote:
>> Have a page which takes the value in $_POST['dropdown'] and performs
>> another SQL query of the desired results.
>>
>> It may be this page (i.e. if $_POST['dropdown'] is set, or a different
>> page, depending on your needs.
>
> Is it possible to make the select element of the form automatically execute
> the "<INPUT type='submit' value='Go'>"; statement rather than having a
> button to click on???
>
Yes, with javascript.
However there are caveats.
If you actually do CHANGE the value displayed, then this code
<SELECT ...onchange="document.forms[0].submit()" >
will submit the form.
if there is only one <OPTION> element IN the select statement, this
doesn't work however. I have a workaround but its ugly. >> Stay informed about: $_SERVER['PHP_SELF'] Question |
|
| Back to top |
|
 |  |
External

Since: Jun 14, 2004 Posts: 14
|
(Msg. 9) Posted: Sat Oct 20, 2007 1:41 pm
Post subject: Re: $_SERVER['PHP_SELF'] Question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
No, You correctly interpreted my question. I just posted to the incorrect
group. Will have a look at the JS group.
--
Yours Sincerely
Kye
"Jerry Stuckle" wrote in message
> Kye wrote:
>>> Have a page which takes the value in $_POST['dropdown'] and performs
>>> another SQL query of the desired results.
>>>
>>> It may be this page (i.e. if $_POST['dropdown'] is set, or a different
>>> page, depending on your needs.
>>
>> Is it possible to make the select element of the form automatically
>> execute the "<INPUT type='submit' value='Go'>"; statement rather than
>> having a button to click on???
>>
>
> Or maybe I misunderstood your question. Why would you want a select
> statement to press a button?
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstucklex DeleteThis @attglobal.net
> ==================
> >> Stay informed about: $_SERVER['PHP_SELF'] Question |
|
| Back to top |
|
 |  |
External

Since: Oct 17, 2007 Posts: 77
|
(Msg. 10) Posted: Sun Oct 21, 2007 4:58 pm
Post subject: Re: $_SERVER['PHP_SELF'] Question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Greetings, Lars Eighner.
In reply to Your message dated Saturday, October 20, 2007, 12:29:09,
LE> Again, this is an html question, having nothing to do with php.
/agree, but...
LE> You can use javascript to make ENTER in some form field submit the form,
You can use "form.submit();" JS call even if there's no "type=submit" fields
in form.
(Just to clarify)
--
Sincerely Yours, AnrDaemon >> Stay informed about: $_SERVER['PHP_SELF'] Question |
|
| Back to top |
|
 |  |
External

Since: Oct 17, 2007 Posts: 77
|
(Msg. 11) Posted: Sun Oct 21, 2007 4:58 pm
Post subject: Re: $_SERVER['PHP_SELF'] Question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Greetings, The Natural Philosopher.
In reply to Your message dated Saturday, October 20, 2007, 14:38:55,
TNP> <SELECT ...onchange="document.forms[0].submit()" >
*THIS* *IS* JavaScript. Actually.
--
Sincerely Yours, AnrDaemon >> Stay informed about: $_SERVER['PHP_SELF'] Question |
|
| Back to top |
|
 |  |
External

Since: Oct 17, 2007 Posts: 77
|
(Msg. 12) Posted: Sun Oct 21, 2007 4:58 pm
Post subject: Sorry, forgive my previous post please. [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
|
|
| Back to top |
|
 |  |
External

Since: Aug 31, 2007 Posts: 173
|
(Msg. 13) Posted: Sun Oct 21, 2007 4:58 pm
Post subject: Re: $_SERVER['PHP_SELF'] Question [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
AnrDaemon wrote:
> Greetings, The Natural Philosopher.
> In reply to Your message dated Saturday, October 20, 2007, 14:38:55,
>
> TNP> <SELECT ...onchange="document.forms[0].submit()" >
>
> *THIS* *IS* JavaScript. Actually.
>
>
That is what I said IIRC.
"Not in php, but its simple with javascript"..
and gave that example. >> Stay informed about: $_SERVER['PHP_SELF'] Question |
|
| Back to top |
|
 |  |
External

Since: Aug 31, 2007 Posts: 173
|
(Msg. 14) Posted: Sun Oct 21, 2007 4:58 pm
Post subject: Re: Sorry, forgive my previous post please. [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
|
|
| Back to top |
|
 |  |
| Related Topics: | $_server[php_self] - hi all i'm having issues with this returned function. I can get it to delete a database but i really want it to grab the stateselect extention and grab all the cities related to that state. I wanted to contain this on one page instead of going over..
PHP_SELF, $_SERVER, etc - Hello news group, This is a dumb question. Sorry. I would like to pass the name of the "page", along with some $_REQUEST variables. I used the $_REQUEST to send and image name (with path) to a page that displays the image referred to in the...
use of $_SERVER['DOCUMENT_ROOT']. - I'm working on a large intranet group site with a lot of pages, file types, folders, subfolders, etc. I am using the include ('../includes/file.php') , but I would like to have a single snippet that will work for all .php/.html pages in all..
$_SERVER variables under IIS6 - Why is it that IIS6 does not provide all the $_SERVER variables, otherwise available underApache ? Examples being, SERVER_ADDR, SERVER_PORT ... Is there any way to declare server variables under IIS ? Thanks
question about safe - question no. 2 - Hello! How to prevent from such try of attack of the website? http://www.domain.com/index.php?id=%3Cscript%3Ealert(document.cookie);%3C/script%3E Thank you in advance for help M. |
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
 |
|
|