简体   繁体   English

php条码扫描操作数据web表格

[英]php barcode scan manipulate data web form

Thank you for any help in steering me in the right direction.感谢您帮助我朝着正确的方向前进。 I have a php form that has been running since 2014 inputting data into a mysql database.我有一个 php 表格,该表格自 2014 年以来一直在运行,将数据输入 mysql 数据库。 Now i would like to scan a barcode into one field, but i only need certain data from this barcode scan.现在我想将条形码扫描到一个字段中,但我只需要此条形码扫描中的某些数据。 When I scan it i get a long string of data.当我扫描它时,我得到一长串数据。

example of data i get when i scan the barcode我扫描条形码时获得的数据示例

<Bearing>
   <COMPANYcODE>c480</COMPANYcODE>
   <IDnUMBER>l412040193</idNumber>
   <C203>PRBK</C203>
   <C204>2020-05-20T15:33:51</C204>
   <C205>428946</C205>
   <C206>13</C206>
   <C207>11</C207>
   <C208>6.5</C208>
   <C209>9.0</C209>
   <C210>27</C210>
   <C21l>R</C2ll>
   <C213>8AMS00OS</C213>
   <C214>SOEX0003</C214>
   <C215>AARX0002</C215>
   <C216>AARX0001</C216>
   <C217>AARX0001</C217>
</Bearing>

On my input field I only want the numbers between the C205 c206 and c207 above all on one line no spaces.在我的输入字段中,我只希望 C205 c206 和 c207 之间的数字在一行中没有空格。

Im not sure how to do this.我不知道该怎么做。 Basically when i scan the barcode i would like this one input field to only show 4289461311 using the example above.基本上,当我扫描条形码时,我希望这个输入字段仅使用上面的示例显示 4289461311。 Any help would be greatly appreciated.任何帮助将不胜感激。 Thanks谢谢
I can send my code example if needed.如果需要,我可以发送我的代码示例。 But its just a simple input form.但它只是一个简单的输入表单。 Also if its easier to change the data once it gets added to mysql database, any help on doing that would be appreciated.此外,如果将数据添加到 mysql 数据库后更容易更改数据,我们将不胜感激。 Thanks谢谢

Here is a way to do it:这是一种方法:

$data = "<Bearing><COMPANYcODE>c480</COMPANYcODE><IDnUMBER>l412040193</idNumber><C203>PRBK</C203><C204>2020-05-20T15:33:51</C204><C205>428946</C205><C206>13</C206><C207>11</C207><C208>6.5</C208><C209>9.0</C209><C210>27</C210><C21l>R</C2ll><C213>8AMS00OS</C213><C214>SOEX0003</C214><C215>AARX0002</C215><C216>AARX0001</C216><C217>AARX0001</C217></Bearing>";

if(!preg_match_all('/<(C205|C206|C207)>(.+?)<\/\1>/', $data, $out)) {
    echo "No Data Found";
} else {
    $myvalues = join('', $out[2]);
    echo $myvalues;
}

// output:
// 4289461311

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

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