通过$ _GET结果循环 [英] loop through $_GET results

查看:133
本文介绍了通过$ _GET结果循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有这样的事情:

 ?FormSub = Submit& qty = 1& partno = ipod& notes = apple& amp ; unitprice = 102.99& rowid = 1& qty = 2& partno = Ear + Buds& notes = Headphones& unitprice = 45.99& rowid = 2 

是否可以遍历GET来将结果返回到HTML表中并添加到SQL表中?



或者我需要添加rowid到每个 $ _ GET 结尾(即 qty 1 = 1&安培; PARTNO 1 $ b

感谢您的关注。


$ b


$ b <你可以通过循环 $ _ GET 来解决问题。它只是一个数组:

  foreach($ _GET as $ key => $ value){} 
code>

当您完成SQL查询时,请记住清理所有输入。同样在页面上显示值。使用 htmlentities 来清理HTML显示。假设你的数据库是MySQL,对SQL使用 mysql_real_escape_string


If I had something like this:

?FormSub=Submit&qty=1&partno=ipod&notes=apple&unitprice=102.99&rowid=1&qty=2&partno=Ear+Buds&notes=Headphones&unitprice=45.99&rowid=2

Is it possible to loop through the GET's to return results into a HTML table and also add to a SQL table?

Or would I need to add the rowid to then end of every $_GET (i.e. qty1=1&partno1=ipod...)?

Thanks for looking.

解决方案

You can loop through $_GET though. It's just an array:

foreach ($_GET as $key => $value) { }

When you go through to make your SQL queries, remember to sanitize all of your inputs. Likewise for displaying values on the page. Use htmlentities to sanitize for HTML display. Assuming your database is MySQL, use mysql_real_escape_string for SQL.

这篇关于通过$ _GET结果循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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