zyrolasting Posted October 23, 2009 Share Posted October 23, 2009 I'm trying to fuel a simple navigation system for a news section. It works fine when it comes to retrieving and displaying data, but if I click on a valid link in the following code, the content and links do not update like they should. All hrefs stay the same and the content does not change. Why is this? require('../scripts/chron.php'); $con = openConnect(); // Get current entry ID, using -1 to mark an unavailable param. $entry = (isset($_GET['id'])) ? $_GET['id'] : -1; // Query table for vital entry info $type = 'news'; $count = getEntryCount($type); // Go to latest entry if param is unavailable. if ( $entry = -1 ) $entry = $count; // Build links for navigation $first = $entry<=1 ? 'undef' : 0; $prev = $entry<=1 ? 'undef' : $entry-1; $next = $entry < $count ? $entry+1 : 'undef'; $last = $entry < $count ? $count : 'undef'; echo '<div class="newsLinks"><p>'; echo ($first != 'undef') ? ('<a href="index.php?id='.$first.'">First</a> - ') : ('First - '); echo ($prev != 'undef') ? ('<a href="index.php?id='.$prev.'">Previous</a> - ') : ('Previous - '); echo ($next != 'undef') ? ('<a href="index.php?id='.$next.'">Next</a> - ') : ('Next - '); echo ($last != 'undef') ? ('<a href="index.php?id='.$last.'">Last</a>') : ('Last'); echo '</p></div>'; $row = getEntryRow($type,$entry); // Display entry echo '<h1 class="centerHead" id="Title">' . $row['title'] . '</h1>'; echo '<h3 class="centerHead" id="DatePosted">' . $row['datePosted']. '</h3>'; echo '<div class="newsBody" id="CurrentContent">' . $row['content'] . '</div>'; Quote Link to comment https://forums.phpfreaks.com/topic/178793-solved-links-not-updating/ Share on other sites More sharing options...
zyrolasting Posted October 24, 2009 Author Share Posted October 24, 2009 Bump. Reason: I still need assistance on this issue, and I have gone about a week without updating my site because of it and similar ones, making it a fairly high priority as I do have content to share. I only ask you be patient with me, as I am still inexperienced. I rephrased my question below in hopes of getting replies. I use a $_GET variable called id, which holds an integer I use to nab a row in a mySQL table. When the page is being parsed, I have 4 links on the page that link to the very same page, but just uses a modified id that is relative to the current one to navigate my database. If I load my page and get to the latest entry (index.php?id=2, for example), and to want to go to the "previous" page, I click on "previous" which links to (index.php?id=1). This was a bare bones system suggested to me on this forum recently. Now, in the code block above you see I use isset and _GET to determine if I need to rely on _GET to choose my page, or if I should get the latest entry instead to start from. In my case I have 2 entries total so far. 'Previous' is clickable and the href I see in the status bar is as I expect... it links to the same page, changing 'id' to 1. FYI, the ids in my table are 1-based. My problem out of all this is that when I click one of these links to fire off my request, nothing gets updated. At all. I just do not understand why. The code block above has some functions not listed here, but they are working and need not be shared. All code in the OP is just a relevant subset. Your assistance will be appreciated. Thank you for your time. Quote Link to comment https://forums.phpfreaks.com/topic/178793-solved-links-not-updating/#findComment-943438 Share on other sites More sharing options...
sloth456 Posted October 24, 2009 Share Posted October 24, 2009 Yeah, I've looked really hard at it and I don't think there's anything wrong with it. The links are are fine. But the content isn't changing as you say. Everything points to there being something up with your getEntryRow() function. May I see it? Quote Link to comment https://forums.phpfreaks.com/topic/178793-solved-links-not-updating/#findComment-943523 Share on other sites More sharing options...
zyrolasting Posted October 24, 2009 Author Share Posted October 24, 2009 Thanks for the reply. You may, but I think it's fine considering I can get at least one entry from it. function getEntryRow($type,$id) { $result = mysql_query("SELECT * FROM " . $type . " WHERE id=" . $id ); if (!is_resource($result)) { die(mysql_error()); } // Grab current entry row $row = mysql_fetch_array( $result ); if ( !$row ) { die('Could not retrieve row: '.mysql_error()); } return $row; } $type is literally a table name from the database selected in the openConnect function in OP. I know everything related to establishing a connection to and querying from mySQL is fine. It's just an issue of being unable to, ehrm, make these queries again. Would the fact I'm on localhost have anything to do with this? I am on WAMPServer/Dreamweaver. I see other forum members have issues where they were suggested to get on a real server. FYI in that respect: My only real server access holds my site. I don't want to debug on my site itself! Quote Link to comment https://forums.phpfreaks.com/topic/178793-solved-links-not-updating/#findComment-943606 Share on other sites More sharing options...
mikesta707 Posted October 24, 2009 Share Posted October 24, 2009 this if ( $entry = -1 ) $entry = $count; should be if ( $entry == -1 ) $entry = $count; besides that i dont see a problem Quote Link to comment https://forums.phpfreaks.com/topic/178793-solved-links-not-updating/#findComment-943607 Share on other sites More sharing options...
zyrolasting Posted October 24, 2009 Author Share Posted October 24, 2009 should be if ( $entry == -1 ) $entry = $count; besides that i dont see a problem ...As it turns out, that was the defining issue. It works now. Thank you for catching that! Having the entry get forced back to $count in OP meant I could never leave the entry I was on. I feel stupid. :-\ Damn one character errors ruin everything! Quote Link to comment https://forums.phpfreaks.com/topic/178793-solved-links-not-updating/#findComment-943610 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.