开发者

Extending URIs with 2 queries (i.e. 'viewauthorbooks.php?authorid=4' AND 'orderby=returndate") Possible?

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 s开发者_StackOverflow中文版ome reason, also I want to know if I am using correct layout to have 2 parameters run in the address? Thanks.


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 &amp; and sanitize your output, but apart from that it's correct ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜