简体   繁体   English

如何从数据库检索值到动态文本框

[英]How to retrieve the value from database to dynamic textbox

First of all, I have done add/remove input fields dynamically with jQuery. 首先,我已经使用jQuery动态完成了添加/删除输入字段。 For example: 例如:

在此处输入图片说明

After, I'm using the implode() function of PHP I have stored dynamic textbox values into MySQL. 之后,我使用PHP的implode()函数将动态文本框值存储到MySQL中。 For example 例如

$capture_field_vals = "";
if(isset($_POST["ItemCode"]) && is_array($_POST["ItemCode"])) {
    $capture_field_vals = implode(",", $_POST["ItemCode"]);     
}

From the above code, I can store Item Code As [1000, 1001, 1004] into the database. 通过上面的代码,我可以将项目代码As [1000, 1001, 1004]到数据库中。 How can I retrieve the same values into a dynamic textbox again so user can edit or update it? 如何再次将相同的值检索到动态文本框中,以便用户可以编辑或更新它?

My PHPMyadmin : 我的PHPMyadmin:

在此处输入图片说明

PurchaserID is same as ItemCode. PurchaserID与ItemCode相同。 So, one lot can be contained one or more purchaser same as one purchaser can purchase one or more item. 因此,可以包含一个或多个购买者一个批次,就像一个购买者可以购买一个或多个项目一样。

Anyone can help me? 有人可以帮助我吗?

Select the PurchaseID as: 选择PurchaseID为:

$query = Select purchaserID from table;

foreach($query as $data){
 $new_data = explode(',',$data);
 foreach($new_data as $row=>$val){
   $htmlRow .= <tr><td><input type="text" val=$val/></td></tr>; 
 }
}

now append $htmlRow to your table. 现在将$ htmlRow附加到表中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM