使用 2 个查询扩展 URI(即“viewauthorbooks.php?authorid=4”和“orderby=returndate”)可能吗?
我的系统中有一个链接,如上所示; 'viewauthorbooks.php?authorid=4' 工作正常并生成一个页面,显示仅与特定作者相关的书籍。不过,我正在实现另一个功能,用户可以对列进行排序(返回日期、书名等),并且我正在使用 ORDER BY SQL 子句。我也按照其他页面的要求工作,这些页面在 URI 中还没有其他查询。但对于这个特定页面,URL 中已经返回了一个参数,并且我在扩展它时遇到了困难。
当用户单击表列标题时,我收到错误,并且原始作者 ID 丢失!
这是我尝试使用的 URI 链接:
<th><a href="viewauthorbooks.php?authorid=<?php echo $row['authorid']?>&orderby=returndate">Return Date</a></th>
这样可以按返回日期的顺序对数据进行排序。当我运行这个时;作者 ID 由于某种原因丢失,我还想知道我是否使用正确的布局在地址中运行 2 个参数?谢谢。
I have a link in my system as displayed above; 'viewauthorbooks.php?authorid=4' which works fine and generates a page displaying the books only associated with the particular author. However I am implementing another feature where the user can sort the columns (return date, book name etc) and I am using the ORDER BY SQL clause. I have this also working as required for other pages, which do not already have another query in the URI. But for this particular page there is already a paramter returned in the URL, and I am having difficulty in extending it.
When the user clicks on the a table column title I'm getting an error, and the original author ID is being lost!!
This is the URI link I am trying to use:
<th><a href="viewauthorbooks.php?authorid=<?php echo $row['authorid']?>&orderby=returndate">Return Date</a></th>
This is so that the data can be sorted in order of Return Date. When I run this; the author ID gets lost for some reason, also I want to know if I am using correct layout to have 2 parameters run in the address? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,布局是正确的。当然,查询字符串中甚至可以有两个以上的参数
您必须检查生成的查询字符串(只需在单击后查看地址栏),必须有类似
viewauthorbooks.php?authorid=22&orderby=returndate
的内容。如果号码丢失,您必须检查它的来源 - $row['authorid'] 变量。Yes, the layout is correct. Of course it's possible to have even more than 2 parameters in the query string
you have to check resulting query string (just take look into your address bar after click), there must be something like
viewauthorbooks.php?authorid=22&orderby=returndate
. If number is lost, you have to check it's source - $row['authorid'] variable.你必须使用
&
并清理你的输出,但除此之外它是正确的;)you have to use
&
and sanitize your output, but apart from that it's correct ;)