
bramabull100
New Members-
Posts
2 -
Joined
-
Last visited
Never
Everything posted by bramabull100
-
Hope this is clear and concise! I have a view article page and every time you land on the page then I have a query that runs an update using sql. Now the problem is everytime the script is run it counts one hit as 2. For example if an article has been viewed 4 times. Next time you land on the page it shows the page has been seen 6 times instead of 5. Here is my code below for the view_article page: <body bgcolor="#000000"> <div id="site_div" align="center"> <div id="wrapper_div"> <!-- header --> <?php include 'header.php'; ?> <!-- header --> <div id="main_nav"> <div id="link1_div"><p class="link1_class"><a href="index.html" class="link1_class">All Articles</a></p></div> <div id="link2_div"><p class="link2_class"><a href="index.html" class="link2_class">Reviews</a></p></div> <div id="link3_div"><p class="link2_class"><a href="index.html" class="link2_class">Previews</a></p></div> <div id="link4_div"><p class="link2_class"><a href="buys.php?lightbox[width]=700&lightbox[height]=400&lightbox[modal]=true" class="link2_class lightbox">Videos</a></p></div> <div id="link5_div"><p class="link2_class"><a href="rents.php?lightbox[width]=700&lightbox[height]=400&lightbox[modal]=true" class="link2_class lightbox">News</a></p></div> <div id="link6_div"><p class="link2_class"><a href="index.html" class="link2_class">Podcasts</a></p></div> <div id="link7_div"><p class="link2_class"><a href="index.html" class="link2_class">Contact Us</a></p></div> <div id="link8_div"><p class="link2_class"><a href="index.html" class="link2_class"></a></p></div> </div> <div id="sub_nav"> <div id="sub_nav_div"> <p class="filter_by_class">FILTER BY: <a href="index.php" style="color:#21a8f7; text-decoration:underline">All</a> <a href="xbox360.php">Xbox 360</a> <a href="#">PS3</a> <a href="#">Wii</a> <a href="#">PC</a> <a href="#">PSP</a> <a href="#">DS</a><a href="#">Mobile</a><a href="#">Older Platforms</a></p></div> </div> </div> <div id="content_div"> <div id="content_spacer"> </div> <!-- TRACK PAGE <span class="posthilit">VIEWS</span> --> <?php //DATABASE CONNECTION include_once 'dbc.php'; $id = $_GET['id']; mysql_query("UPDATE articles SET `article_views` = `article_views`+1 WHERE idarticles='$id'"); ?> // TrACK PAGE <span class="posthilit">VIEWS</span> // MAIN CONTENT if(isset($_GET['id']) && is_numeric($_GET['id']) ) { $query = "SELECT * FROM articles WHERE idarticles= {$_GET['id']}"; if($r = mysql_query($query)) { $row = mysql_fetch_array($r); echo " <div id=\"main_article_div\"> <div id=\"top_blue_content_div\"> {$row['article_type']}</div> <div id=\"image_main_content_div\"><img src=\"{$row['article_big_image']}\" width=\"200\" height=\"112\" alt=\"main_article_image\" /></div> <div id=\"content_area\"><p class=\"main_content_title_class\">{$row['article_title']} <div id=\"addthisspacer\"> <!-- AddThis Button BEGIN --> <div class=\"addthis_toolbox addthis_default_style \"> <a class=\"addthis_button_facebook_like\" fb:like:layout=\"button_count\"></a> <a class=\"addthis_button_tweet\"></a> <a class=\"addthis_counter addthis_pill_style\"></a> </div> <script type=\"text/javascript\" src=\"http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4d1d4fb34dc87309\"></script> <!-- AddThis Button END --> </div> </p> </div> </div> "; } } ?> <!-- MAIN CONTENT ENDS --> </div> <div id="lower_content_div"> <!-- THIS IS WHERE THE MAIN ARTICLE/COMMENTS STARTS --> <?php //include 'dbc.php'; if(isset($_GET['id']) && is_numeric($_GET['id']) ) { $query = "SELECT * FROM articles WHERE idarticles= {$_GET['id']}"; if($r = mysql_query($query)) { $row = mysql_fetch_array($r); echo " <div id=\"left_lower_content\" class=\"break-word\"> {$row['actual_article']} </div> "; } } ?> <!-- THIS IS THE END OF THE MAIN ARTICLE/COMMENTS QUERY --> </div> <div id="footer_div"> <div id="footer_1"></div> <div id="actual_footer"> <div id="top_footer_div"> <div id="top_footer_div_left"><a href="login.php?lightbox[width]=396&lightbox[height]=200&lightbox[modal]=true"><img src="images/rent-or-buy-2-logo_small2.png" width="260" height="39" alt="small_logo" class="small_logo_class" /></a></div> <div id="top_footer_div_right"> <div id="login_register_div_2"> <p class="logintext"><a href=""><img src="images/rss_icon.png" width="16" height="16" alt="rss_icon" /></a></p><p class="logintext"><a href="http://www.twitter.com"><img src="images/twitter_icon.png" width="16" height="16" alt="twitter_icon" /></a></p><p class="logintext"><a href="http://www.youtube.com"><img src="images/youtube_icon.png" width="38" height="16" alt="youtube_icon" /></a></p><p class="logintext"><a href="http://www.facebook.com"><img src="images/facebook_icon.png" width="16" height="16" alt="facebook_icon" /></a></p> </div> </div> <div id="search_div2"> <form action="#" method="post" name="search"> <input type="text" value="Search!" class="formimage" /> <INPUT TYPE="IMAGE" src="images/search_bar_button.jpg" BORDER="0" style="padding:0" class="formbutton"> </form> </div> </div> <div id="actual_footer_bottom_section"> <div id="actual_footer_bottom_section_top"></div> <div id="actual_footer_bottom_section_top_links"><a href="index.php">All Articles</a> | <a href="#">Reviews</a> | <a href="#">Previews</a> | <a href="#">"Buys"</a> | <a href="#">"Rents"</a> | <a href="#">Videos</a> | <a href="#">News</a> | <a href="#">Games</a> </div> <div id="actual_footer_bottom_section_bottom"> <p class="actual_footer_bottom_section_paragraph">Design By: Felix Henriques | Created By: Felix Henriques | Copyright 2010 Buy Or Rent Games</p></div> <div id="actual_footer_bottom_section_top"></div> </div> </div> </div> </div> </div> </body> </html>
-
Hey guys, I have been using this code for Pagination found at the following link: http://phpsense.com/php/php-pagination-script.html. Now this calls up a class which uses a LIMIT function internally. So the code works great and is retrieving the results I want except I want to skip the first row it returns. Now I know this is generally a weird request but I want to skip the first row and start on the second. So instead of starting the while loop on row [0] I want it to start on row [1]. I hope I explained this clearly enough if not just let me know. Thanks for the help! My Code: <!-- THIS IS WHERE THE MAIN SUB CONTENT QUERY STARTS --> <?php //Include the PS_Pagination class include('ps_pagination.php'); //Connect to mysql db $conn = mysql_connect('localhost', 'username', 'password'); mysql_select_db('test_db',$conn); //$sql = 'SELECT * FROM articles WHERE article_type ="News" AND idarticles="70" ORDER BY date_uploaded DESC'; //To sort it by certain article type $sql = 'SELECT * FROM articles ORDER BY date_uploaded DESC'; //Create a PS_Pagination object $pager = new PS_Pagination($conn, $sql, 8, 10, 'param1=valu1¶m2=value2'); //The paginate() function returns a mysql //result set for the current page $rs = $pager->paginate(); //Loop through the result set //DEFAULT SKIPS FIRST RECENT BECAUSE IT WILL DUPLICATE while($row = mysql_fetch_assoc($rs)) { echo " <div id=\"left_lower_content\"> <div id=\"left_lower_content_top\"><p class=\"left_lower_content_top_class\">{$row['article_type']}</p></div> <div id=\"left_lower_content_image\"><a href=\"view_article.php?id={$row['idarticles']}&lightbox[width]=950&lightbox[height]=700&lightbox[modal]=true\" class=\"lightbox\"><img name=\"left_lower_content_image\" src=\"{$row['article_big_image']}\" width=\"300\" height=\"170\" alt=\"\" style=\"background-color: #999999\" /></a></div> <div id=\"left_lower_content_main_text\"> <p class=\"left_lower_content_title lightbox\"><a href=\"view_article.php?id={$row['idarticles']}lightbox[width]=1000&lightbox[height]=200&lightbox[modal]=true\">{$row['article_title']}</a></p> <p class=\"left_lower_content_text\">{$row['small_description']}</p> </div> <a href=\"view_article.php?id={$row['idarticles']}lightbox[width]=1000&lightbox[height]=200&lightbox[modal]=true\"><img src=\"images/full_article.jpg\" width=\"86\" height=\"15\" alt=\"full_article\" class=\"full_article_sub_article lightbox\" /></a> <div id=\"left_lower_content_bottom_div\"><p class=\"left_lower_content_bottom\">Posted by: Felix Henriques | {$row['views']} Views | Posted on: {$row['date_uploaded']} | <a href=\"#\">{$row['comments']} Comments</a></p></div> <div id=\"left_lower_spacer\"></div> </div> "; ; } //Display the navigation echo'<div id="pagination">'; echo'<p class="pagination">'; echo $pager->renderFullNav(); echo'</p>'; echo'</div>'; ?>