PHP:使用input =隐藏类型数据从表单中获取MySQL数据 [英] PHP: using input=hidden type data from form to get MySQL data

查看:83
本文介绍了PHP:使用input =隐藏类型数据从表单中获取MySQL数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是PHP的新手,但已经使用了大约一个星期。当输入类型=文本时,我使用html表单从MySQL表中调用数据没有问题,但是当输入类型=隐藏时,我似乎无法找到从MySQL表中调用数据的方法。


这里是表格代码:


[PHP]

<?php $ action = $ _REQUEST [' 'action''];

$ epic = $ _REQUEST [''epic'']; ?>


< TR>

< TD>


<?php echo $ action ; ?>


< INPUT TYPE =" HIDDEN" NAME ="动作" VALUE ="


<?php

echo $ action; ?>


">< / TD>

< TD>


< ?php

echo $ epic; ?>


< INPUT TYPE =" HIDDEN" NAME ="史诗" VALUE ="


<?php

print $ epic; ?>


" SIZE =4>< / TD>

< TD>< INPUT TYPE =" TEXT" NAME ="体积" SIZE =5>< / TD>

< TD> < / TD>

< TD> < / TD>

< / TR>

< / TABLE>

< P>< INPUT TYPE =" SUBMIT" VALUE =获取报价< / P>

< / FORM>

[/ PHP]


和DB调用:


<?php $ getquote = @ mysql_query(" SELECT EPIC,SharePrice FROM SharePrices WHERE EPIC =''$ epic''");


变量$ epic首次在URL中从另一个页面传递,然后在表单中显示为文本,但存储为隐藏数据,因为我不希望用户能够更改它。如果我从select中删除where子句或插入一个值,数据会很好。 EPIC = ABC或在查询之前设置$ epic = ABC。然而问题是在传递之后$ epic中包含的数据。我用echo来显示它,它看起来不错。我已经使用各种字符串函数来删除空格等但都无济于事。字段EPIC在MySQL表上定义为CHAR(4)并且是主键。


任何人都有帮助吗?


干杯。

I am new to PHP but have been using it for about a week. I''m having no trouble using html forms to recall data from a MySQL table when the input type=text but i cant seem to find a way of recalling the data from the MySQL table when the input type=hidden.

Here''s the form code:

[PHP]
<?php $action = $_REQUEST[''action''];
$epic = $_REQUEST[''epic'']; ?>

<TR>
<TD>

<?php echo $action; ?>

<INPUT TYPE="HIDDEN" NAME="action" VALUE="

<?php
echo $action; ?>

"></TD>
<TD>

<?php
echo $epic; ?>

<INPUT TYPE="HIDDEN" NAME="epic" VALUE="

<?php
print $epic; ?>

" SIZE="4"></TD>
<TD><INPUT TYPE="TEXT" NAME="volume" SIZE="5"></TD>
<TD> </TD>
<TD> </TD>
</TR>
</TABLE>
<P><INPUT TYPE="SUBMIT" VALUE="Get Quote"</P>
</FORM>
[/PHP]

And the DB call:

<?php $getquote=@mysql_query("SELECT EPIC,SharePrice FROM SharePrices WHERE EPIC = ''$epic''");

The variable $epic is passed through first time in the URL from another page and is then displayed in the form as text but stored as hidden data as i dont want the user the ability to change it. The data comes back fine if I remove the where clause from the select or plug in a value eg. EPIC=ABC or set $epic=ABC before the query. The problem however is the data contained in $epic after it is passed through. i have used echo to display it and it looks ok. i have used various string function to remove spaces etc but all to no avail. The field EPIC is defined as CHAR(4) on the MySQL table and is the primary key.

Anybody got any help?

Cheers.

推荐答案

action =


_REQUEST [''action''];
_REQUEST[''action''];


epic =


这篇关于PHP:使用input =隐藏类型数据从表单中获取MySQL数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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