Thanks Andy, I had tried something similar to the above except I did not have a if loop in between. I put the above code just above the previous code. Anyway, with the above code (and what I tried earlier) returns all links in the database ie. it prints all the links in the database regardless of the catname input value but if I don't enter any catname it will revert back to the search form meaning, when a catname is provided it seems to be looking up for the corresponding catid but prints out all links. If you do come up with a solution later, please do let me know.Thanks!