ozone1 Posted January 26, 2008 Share Posted January 26, 2008 Hi im having problem with page views on my site it is not adding views automatically to the database on clicking a link when i put values manually to the database its showing on the site can anyone tell what codes do i need to put 2 make it work. I dont know anything on php so it will be great if you give step by step instructions. Thanks Here is my code : <div class="googleHor"> ads </div> <div id="content"> <? $media = $_GET['id']; $result = mysql_query("SELECT * FROM category WHERE id='$media'"); while($row = mysql_fetch_array($result)) { $id = $row['ID']; $title = $row['name']; } ?> <div class="bigTitle"><? echo $title; ?> </div> <div class="alpha"> Find what to watch alphabetically (e.g <b>P</b> for Pokkiri) <b>OR</b> use the search box at the top. <ul> <?php $alpha = array("0-9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"); for($i=0;$i<count($alpha);$i++) { if($_GET["limit"]==$alpha[$i]) { } else { } echo '<li><a href="main.php?id='.$category.'&limit='.$alpha[$i].'">'. $alpha[$i] . '</a></li>'; } ?> </ul> </div> <!-- Closes alpha --> <div class="sort"> Sort by: <span class="sortType" onclick="document.location='?sortby=views';">Most Viewed</span><span class="sortType" onclick="document.location='?sortby=latest';">Latest Added</span> </div> <!-- Closes sort --> <div class="listing"> <table id="listing" cellspacing="0" cellpadding="0" > <?php landbanner(); $display = 25; // RETRUN THIS MANY RESULTS // Determain how many categories there are. if(isset($_GET['np'])) { // Already been determined $num_pages = $_GET['np']; } else { // Count the number of recorde $numQuery = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM videos WHERE category='".$category."' ORDER BY id ASC"), MYSQL_NUM); $num_records = $numQuery[0]; // Calculate the number of pages if($num_records > $display) { // More than 1 category $num_pages = ceil($num_records/$display); } else { $num_pages = 1; } } // End of np IF // Determina where in the database to start returning results if(isset($_GET['s'])) { $start = $_GET['s']; } else { $start = 0; } if(!isset($_GET['page'])){ // SEE IF A PAGE LETTER HAS BEEN SELECTED. // IF ONE HASNT BEEN SELECTED, SHOW ALL LISTINGS $mresult = mysql_query("SELECT * FROM videos WHERE category='".$category."' ORDER BY title ASC LIMIT $start,$display"); $plusView = mysql_query( "UPDATE videos SEL view = $vn WHERE id = $sID" ); //$mresult = mysql_query("SELECT * FROM videos WHERE category='".$category."' ORDER BY title ASC LIMIT $start,$display"); while($row = mysql_fetch_array($mresult)) { $id = $row['id']; $title = $row['title']; $numviews = $row['view']; $vn = $numviews + 1; if($numviews<=0) { $viewtime = '<span> ' . $numviews . ' Views</span>'; } else { $viewtime = '<span> ' . $numviews . ' Views</span>'; } ?> <tr> <td style="width:500px;"> <? if($seo == 0) { ?> <a href="<? echo URL; ?>videos.php?id=<? echo $id ?>&vn=<?=$vn?>&sID=<?=$id?>"><? echo $title ?></a><br> <? } ?> <td style="width:100px;color:#4d4d4d;font-size:12;"><? echo $viewtime ?></td> <? if($seo == 1) { ?> <a href="<? echo URL; ?>videos/<? echo $id ?>&vn=<?=$vn?>&sID=<?=$id?>"><? echo $title ?></a><br> <? } } ?> </td> <? } else { } ?> </tr> <tr> <td><? echo landbanner(); ?></td></tr> </table> <div class="pagination"> <? // Make the links to the other pages if necessary if($num_pages > 1) { // Determine what page the script is on $current_page = ($start/$display) + 1; // If it's not the first page, make a previous button if($current_page != 1) { echo '<a href="?id='.($category).'&s='.($start - $display).'&np='.$num_pages.'">Previous</a> '; } // Make all the numbered pages for ($i=1;$i<=$num_pages;$i++) { if($i != $current_page) { echo '<a href="?id='.($category).'&s='.(($display * ($i - 1))).'&np='.$num_pages.'">'.$i.'</a> '; } else { echo $i.' '; } } // If it's not the last page, make a Next button if($current_page != $num_pages) { echo '<a href="?id='.($category).'&s='.($start + $display).'&np='.$num_pages.'">Next</a>'; } } // End of links section ?> </ul> </div> Quote Link to comment https://forums.phpfreaks.com/topic/87957-can-anyone-help-me/ Share on other sites More sharing options...
revraz Posted January 26, 2008 Share Posted January 26, 2008 You may want to learn some, there are quite a few tutorials around. I dont know anything on php so it will be great if you give step by step instructions. Quote Link to comment https://forums.phpfreaks.com/topic/87957-can-anyone-help-me/#findComment-450036 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.