通过$ _GET结果循环 [英] loop through $_GET results
问题描述
如果我有这样的事情:
?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¬es=apple&unitprice=102.99&rowid=1&qty=2&partno=Ear+Buds¬es=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. qty
1
=1&partno
1
=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屋!