BlackKite Posted July 6, 2007 Share Posted July 6, 2007 Ok, so basically designing myself a management system for my one site so that its easier for me and the people that help me to upload pages. I've been doing good with it until now. What i'm trying to do is get my navigation links so print themselves in their correct categories. I've been able to call them from SQL and be turned into links, but I can't seem to figure out how to sort them into the categories. In MySQL I have three pages; one, two, and main. One and Two have an ID_CAT of 2 and Main has and ID_CAT of 1. My goal is to list them in order of ID_CAT 1 then 2 on my navigation, but without having to actually state 1 and 2. For example, and if statement of "if ID_CAT = 1 echo". <- thats what I don't want to have to do because I'm trying to make this so that I don't have to go into my actual files ever again, and everything can be done via a nice neat control panel. Here's my navigation code so far. $query = "SELECT * FROM pages"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<a href=\"http://www.neohound.com/sms/ver1/index.php?id=1&url="; echo $row['url']; echo "\">"; echo $row['name']; echo "</a>"; echo "<br />"; } If anyone can be kind enough to at least point me in the right direction, i would greatly appreciate it. Thanks so much! :'( I'm a complete n00b at this SQL stuff, haha. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 6, 2007 Share Posted July 6, 2007 I think you're wanting to change the order in which you pull the data from the tables - "pages" in this case. You can accomplish this by adding an "ORDER BY" clause on the end, somethign like this: SELECT * FROM `pages` ORDER BY `two` ASC ASC means sort in ascending order. You can also use DESC to reverse sort. Quote Link to comment Share on other sites More sharing options...
BlackKite Posted July 6, 2007 Author Share Posted July 6, 2007 Nah, I want to be able to pull by its ID and put certain ID's in certain spots. However, this still might help. Haha, thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.