tags:

views:

32

answers:

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.

+1  A: 

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.

Col. Shrapnel
Hi Col. Shrapnel...I managed to retrieve the authorid back into the URI, by adding this after my query;$row = mysql_fetch_array($result);However, for some strange reason, the first book in the list disappears!!?? After the table headings have been declared, I again declare the row variable, could this be messsing things up? I have this: 'while($row = mysql_fetch_array($result))'
Jess
@Jess ummm. probably you have to find another source for your author idd. Try to remove that additional mysql_fetch_array($result); and use $_GET['authorid'] instead of $row['authorid'] in your hyperlink
Col. Shrapnel
IGNORE! Instead of echoing the $row variable for author ID, I used '<?php echo $authorid?>' as the link, and it carries the authorid just as required :D:D
Jess
Yes I did use $_GET method as you have stated also! Forgot to mention that part. Thanks for your help Colnel
Jess
double :) `*high five*` :)
Col. Shrapnel
A: 

you have to use &amp; and sanitize your output, but apart from that it's correct ;)

knittl
Syom
becaue `)
knittl