来自MySQL的PHP​​自动填充文本框 [英] PHP autofill text box from MySQL

查看:101
本文介绍了来自MySQL的PHP​​自动填充文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我意识到这可能是一个简单的解决方案,但我只学习了几个星期的PHP和MySQL。我正在尝试编写一个使用MySQL数据库存储发票,产品定价和客户联系信息的发票系统。我想在输入姓名后输入客户的联系信息,并在输入产品名称后输入产品定价信息。根据我的搜索,我发现onChanged事件可能正是我正在寻找的。但是,这似乎只能引用JavaScript和AJAX。有没有办法在PHP中使用它?我已经做了一些搜索但很少了解JS和AJAX。


为了确保我的问题清楚,我不希望用户必须点击一个用于填写数据的按钮,我不想重新加载页面。我只是希望客户联系信息和定价信息在从相应的名称文本框中跳出后自动从数据库中填写。 I.E.输入名字和姓氏,按Tab键,然后手机和地址自动填写自己的文本框。或者输入产品名称并按Tab键,价格信息会自动填入自己的文本框。


很抱歉这么啰嗦。有什么建议?我应该发布哪些代码可以提供帮助吗?我可以提交表格并更新我的数据库没有任何问题,我只是不知道从哪里开始这个。


谢谢,

Dybs

I realize this should probably be a simple solution, but I have only been learning PHP and MySQL for a couple weeks. I am attempting to write an invoicing system that uses a MySQL database to store invoices, product pricing, and customer contact info. I would like to automatically fill in the customer''s contact info after typing in the first and last name, and the product pricing info after typing in the product name. From my searches I''ve found that the onChanged event may be what I''m looking for. However, this only seems to reference JavaScript and AJAX. Is there a way to use this just with PHP? I''ve done some searching but have very little understanding of JS and AJAX.

Just to make sure my question is clear, I don''t want the user to have to click a button to fill in the data, and I don''t want to have to reload the page. I just want the customer contact info and pricing info to automatically fill in from the database after tabbing out of the corresponding name text box. I.E. type in first and last name, press Tab, then the phone and address automatically fill in their own text boxes. Or type a product name and press tab, and the pricing info automatically fills in its own text box.

Sorry for being so long-winded. Any suggestions? Is there any code I should post that would help? I can submit the form and update my database w/o any problems, I just have no clue where to begin on this one.

Thanks,
Dybs

推荐答案

http ://www.w3schools.com/php/php_ajax_database.asp

在此示例中,可以从列表菜单中选择FirstName和LastName,其他详细信息将使用Http Resqusts / Responses显示。您需要做的就是根据您的要求获得概念并制作它。如果您有任何疑问,请随时提出。祝你好运!
http://www.w3schools.com/php/php_ajax_database.asp
In this example can select the FirstName and LastName from a list menu and other details will display using Http Resqusts/Responses. what you have to do get the concept and make it as per your requirement. If you have any doubt please feel free to ask. Good luck!


Ajaxrand,


感谢您的信息。它看起来几乎就是我需要的东西。但是,它只是将信息填充为表格格式。我希望信息进入用户可以编辑的文本框(例如,如果客户移动并需要更改电话号码等)。我知道在文本框中指定值的唯一方法是它是由< input type =" text"创建的。值= QUOT;东西取代。还有其他地方我可以指定某事吗?对于文本框?


谢谢
Ajaxrand,

Thanks for the info. It looks to be almost exactly what I need. However, it only looks to fill the info into a table format. I''d like the info to go into text boxes that the user can edit (say, if the customer moves and needs to change a phone number or something). The only way I know to specify a value in a text box is when it''s created by <input type="text" value="something>. Is there anywhere else I can specify the "something" for the text box?

Thanks



Ajaxrand,

感谢您的信息。它看起来几乎就是我需要的东西。但是,它只是将信息填充为表格格式。我希望信息进入用户可以编辑的文本框(例如,如果客户移动并需要更改电话号码等)。我知道在文本框中指定值的唯一方法是它是由< input type =" text"创建的。值= QUOT;东西取代。还有其他地方我可以指定某事吗?对于文本框?


谢谢
Ajaxrand,

Thanks for the info. It looks to be almost exactly what I need. However, it only looks to fill the info into a table format. I''d like the info to go into text boxes that the user can edit (say, if the customer moves and needs to change a phone number or something). The only way I know to specify a value in a text box is when it''s created by <input type="text" value="something>. Is there anywhere else I can specify the "something" for the text box?

Thanks



这里,如果你在表单中使用post方法,这就是它看起来会像在第二页上,它会告诉你如何在文本框中嵌入php值。


首页,callinvoice.html


[HTML]

< form action =" get_invoice.php" method =" post">

名字:< input name =" first_name"类型= QUOT;文本" size =" 20">< br>

姓氏:< input name =" last_name"类型= QUOT;文本" size =" 20">

< input type =" sumbit" value =" Submit">

< / form>

[/ HTML]


第二页,get_invoice。 php


[PHP]

<?php

Here, if you used a post method in a form, this is what it would look like but on the second page, it shows you how to embed php values in a text box.

First Page, callinvoice.html

[HTML]
<form action="get_invoice.php" method="post">
First Name: <input name="first_name" type="text" size="20"><br>
Last Name: <input name="last_name" type="text" size="20">
<input type="sumbit" value="Submit">
</form>
[/HTML]

Second Page, get_invoice.php

[PHP]
<?php


这篇关于来自MySQL的PHP​​自动填充文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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