PHP Post可以没有表格吗? [英] Can PHP Post without a form?

查看:91
本文介绍了PHP Post可以没有表格吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PHP格式从MySql

表格中动态创建的下拉列表。这是页面上唯一的元素。对于某些记录,单个选择只有

,如果是这样的话我想发布它并且

转到下一页。使用POST有一种简单的方法吗?我知道

怎么用GET做,但不喜欢结果的URL。


或者是否有更简单的方法我不是想想?


谢谢,

拉里

I have a dropdown list dynamically created in a form by PHP from a MySql
table. This is the only element on the page. For some records there is only
a single selection, and if that''s the case I''d like to just post that and
go to the next page. Is there a simple way to do that using POST? I know
how to do it with GET, but don''t like the resulting URLs.

Or is there a simpler method I''m not thinking about?

Thanks,
Larry

推荐答案

7月20日,4:07 pm,Larry L [在檀香山] < la ... @ no-place.org>

写道:
On Jul 20, 4:07 pm, "Larry L [in Honolulu]" <la...@no-place.org>
wrote:

>

I有一个下拉列表,由PHP从MySql表中以
的形式动态创建。这是页面上唯一的元素

。对于某些记录,只有一个

选择,如果是这样的话,我只想发布那个
并转到下一页。有没有简单的

方式使用POST来做到这一点?
>
I have a dropdown list dynamically created in a form
by PHP from a MySql table. This is the only element
on the page. For some records there is only a single
selection, and if that''s the case I''d like to just
post that and go to the next page. Is there a simple
way to do that using POST?



是的,但它与PHP无关:


< form method =" POST" ; action =" [your_action_goes_here]">

< select name =" mySelect" id =" mySelect"

onChange =" mySelect.form.submit()">

< option value ="">选择一个选项

< option value =" 1">选项1

< option value =" 2">选项2

<选项值=" 3">选项3

<选项值=" 4">选项4

< / select>

< / form>


干杯,

NC

Yes, but it''s got nothing to do with PHP:

<form method="POST" action="[your_action_goes_here]">
<select name="mySelect" id="mySelect"
onChange="mySelect.form.submit()">
<option value="">Select an option
<option value="1">Option 1
<option value="2">Option 2
<option value="3">Option 3
<option value="4">Option 4
</select>
</form>

Cheers,
NC


NC< nc@iname.comwrote in news:1184973751.142209.176900

@ d30g2000prg.googlegroups.com:
NC <nc@iname.comwrote in news:1184973751.142209.176900
@d30g2000prg.googlegroups.com:

七月20,4:07 pm,Larry L [在檀香山] < la ... @ no-place.org>

写道:
On Jul 20, 4:07 pm, "Larry L [in Honolulu]" <la...@no-place.org>
wrote:

>>
我有一个下载列表由PHP从MySql表中以形式动态创建。这是页面上唯一的元素
。对于某些记录,只有一个
选择,如果是这样,我只想发布它并转到下一页。有没有一种简单的方法可以使用POST来做到这一点?
>>
I have a dropdown list dynamically created in a form
by PHP from a MySql table. This is the only element
on the page. For some records there is only a single
selection, and if that''s the case I''d like to just
post that and go to the next page. Is there a simple
way to do that using POST?



是的,但它与PHP无关:


< form method =" POST" ; action =" [your_action_goes_here]">

< select name =" mySelect" id =" mySelect"

onChange =" mySelect.form.submit()">

< option value ="">选择一个选项

< option value =" 1">选项1

< option value =" 2">选项2

<选项值=" 3">选项3

<选项值=" 4">选项4

< / select>

< / form>


干杯,

NC


Yes, but it''s got nothing to do with PHP:

<form method="POST" action="[your_action_goes_here]">
<select name="mySelect" id="mySelect"
onChange="mySelect.form.submit()">
<option value="">Select an option
<option value="1">Option 1
<option value="2">Option 2
<option value="3">Option 3
<option value="4">Option 4
</select>
</form>

Cheers,
NC



非常感谢,但也许我没有解释得那么好。我有很多

,正如你所展示的那样,但有时当页面加载,并且创建了

选项列表时,那里只有一个项目。如果这是

的情况,那么我不想显示它,我只想要一个选项

张贴到下一页。 />

Larry

Well thanks, but maybe I didn''t explain it well enough. I have pretty
much exactly what you show, but sometimes when the page loads, and the
options list is created, there is only one item there. If that''s the
case, then I don''t want to even show it, I just want the one option
posted to the next page.

Larry


.. oO(Larry L [在檀香山])
..oO(Larry L [in Honolulu])

>非常感谢,但也许我说得不够好。我很清楚你所展示的内容,但有时当页面加载,并且创建了
选项列表时,那里只有一个项目。如果那是
的情况,那么我不想显示它,我只想将一个选项
发布到下一页。
>Well thanks, but maybe I didn''t explain it well enough. I have pretty
much exactly what you show, but sometimes when the page loads, and the
options list is created, there is only one item there. If that''s the
case, then I don''t want to even show it, I just want the one option
posted to the next page.



简而言之:您希望将哪些信息发布到下一个

页面?


有点长:向客户发送一个表单,只是为了让它回来

立即不仅非常难看,而且非常不可靠,因为

它需要JavaScript。根据必须发送的信息,可能有更好的方法(例如服务器端重定向,

会话,CURL,......)


Micha

In short: What kind of informations do you want to post to the next
page?

A bit longer: Sending a form to the client, just to have it posted back
immediately is not only really ugly, but also highly unreliable, since
it requires JavaScript. Dependent on the informations that have to be
sent around, there might be better ways (e.g. a server-side redirect,
sessions, CURL, ...)

Micha


这篇关于PHP Post可以没有表格吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆