zyrolasting Posted October 22, 2009 Share Posted October 22, 2009 Hey guys. EDIT: Sorry about the double post! I misclicked. I'm trying to make a bare bones news section with 4 links to navigate: First, Previous, Next, Last. That's it. However, I could not get the thing to work for several days and I need to update my site! I tried using AJAX and it failed on IE and FF. I called Brinkster asking about what several forums suggest: that AJAX can fail on a local host. The rep tells me that if it doesn't work for me, it probably won't work on the server, so... nuts. What is the BARE MINIMUM I can do to set up a respectable chronological archive using WAMP? I am an utter novice that honestly has no idea. Whether it's using a cookie to keep track of the current entry the user is on or AJAX, I failed somewhere and I don't have some debugging IDE that I know of to help me see why. I'm not asking for code or any sort of freebie. I just need to know where to start because it's apparent I have no clue what I'm doing. :'( My experience with XHTML and JS is great. I know PHP's syntax and how/where the code runs, but it's server-side only execution is really awkward for me! I'm still taking my first steps. My site is already online, and I'm itching to update it. Link to comment https://forums.phpfreaks.com/topic/178653-solved-why-am-i-having-such-trouble-with-this-wamp/ Share on other sites More sharing options...
zyrolasting Posted October 22, 2009 Author Share Posted October 22, 2009 Hey guys. I'm trying to make a bare bones news section with 4 links to navigate: First, Previous, Next, Last. That's it. However, I could not get the thing to work for several days and I need to update my site! I tried using AJAX and it failed on IE and FF. I called Brinkster asking about what several forums suggest: that AJAX can fail on a local host. The rep tells me that if it doesn't work for me, it probably won't work on the server, so... nuts. What is the BARE MINIMUM I can do to set up a respectable chronological archive using WAMP? I am an utter novice that honestly has no idea. Whether it's using a cookie to keep track of the current entry the user is on or AJAX, I failed somewhere and I don't have some debugging IDE that I know of to help me see why. I'm not asking for code or any sort of freebie. I just need to know where to start because it's apparent I have no clue what I'm doing. :'( My experience with XHTML and JS is great. I know PHP's syntax and how/where the code runs, but it's server-side only execution is really awkward for me! I'm still taking my first steps. My site is already online, and I'm itching to update it. Link to comment https://forums.phpfreaks.com/topic/178653-solved-why-am-i-having-such-trouble-with-this-wamp/#findComment-942347 Share on other sites More sharing options...
cags Posted October 22, 2009 Share Posted October 22, 2009 One of the most common methods for tracking page in this situation is the url. For example... http://www.mysite.com/news/?page=2 $cur_page = $_GET['page']; $row = mysql_fetch_assoc(mysql_query("SELECT COUNT(id) as page_count FROM table")); $page_count = $row['page_count']; echo '<a href="/news/?page=1">First</a>'; echo '<a href="/news/?page="'.$cur_page-1.'">Prev</a>'; echo '<a href="/news/?page="'.$cur_page+1.'">Next</a>'; echo '<a href="/news/?page='.$page_count.'">Last</a>'; Disclaimer: There are lots of 'holes' in security here, it's just to give you an idea. Link to comment https://forums.phpfreaks.com/topic/178653-solved-why-am-i-having-such-trouble-with-this-wamp/#findComment-942353 Share on other sites More sharing options...
zyrolasting Posted October 22, 2009 Author Share Posted October 22, 2009 Disclaimer: There are lots of 'holes' in security here, it's just to give you an idea. And that is indeed all I need. Thank you very much. I had something a little like this, but it was on the other side of the non-functioning AJAX layer. Hell, I'll refresh the page if I have to as long as I can get it to work at first. Just out of curiosity, what are the security holes? If this method is common, they can't be that bad, right? Link to comment https://forums.phpfreaks.com/topic/178653-solved-why-am-i-having-such-trouble-with-this-wamp/#findComment-942370 Share on other sites More sharing options...
cags Posted October 22, 2009 Share Posted October 22, 2009 They are more bugs than 'security holes' as the code stands at the moment. If $cur_page is equal to 1 or $page_count then the previous/next buttons will break. It doesn't validate what it's getting from $_GET['page'] so if the person types ?page=cheese in the url then it will mess up. This would turn into a security flaw if you used... "SELECT * FROM table WHERE id = $cur_page" etc. etc. Link to comment https://forums.phpfreaks.com/topic/178653-solved-why-am-i-having-such-trouble-with-this-wamp/#findComment-942381 Share on other sites More sharing options...
zyrolasting Posted October 23, 2009 Author Share Posted October 23, 2009 Wait, there is something else I don't understand. What kind of URL is this? It doesn't look complete. /news/?page=X I got your suggestion partially... What I did was have the PHP link to the same page I'm on with a different id param. Link to comment https://forums.phpfreaks.com/topic/178653-solved-why-am-i-having-such-trouble-with-this-wamp/#findComment-942503 Share on other sites More sharing options...
cags Posted October 23, 2009 Share Posted October 23, 2009 The first / takes you to your site root so in the users browser they would actually see http://www.example.com/news/?page=X the reason the end looks like that is because I think that's a darn site neater than http://www.example.com/news/index.php?page=X. Essentially speaking it is loading the DirectoryIndex of the news folder, this by default is index.php (or .html). Link to comment https://forums.phpfreaks.com/topic/178653-solved-why-am-i-having-such-trouble-with-this-wamp/#findComment-942508 Share on other sites More sharing options...
zyrolasting Posted October 23, 2009 Author Share Posted October 23, 2009 Ok then. I guess I need to force a refresh of the page in order for my content to update on this system though, right? I still am not able to go back to an older entry. Everything else seems fine at this point. Thank you thus far! Link to comment https://forums.phpfreaks.com/topic/178653-solved-why-am-i-having-such-trouble-with-this-wamp/#findComment-942525 Share on other sites More sharing options...
cags Posted October 23, 2009 Share Posted October 23, 2009 You shouldn't need to 'force' anything. The links I suggested are standard url anchor links, clicking on them will resubmit a request for the page. Link to comment https://forums.phpfreaks.com/topic/178653-solved-why-am-i-having-such-trouble-with-this-wamp/#findComment-942532 Share on other sites More sharing options...
zyrolasting Posted October 23, 2009 Author Share Posted October 23, 2009 Weird. Ok, I'll just tinker with it, then. Thank you for all the help! Link to comment https://forums.phpfreaks.com/topic/178653-solved-why-am-i-having-such-trouble-with-this-wamp/#findComment-942714 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.