Need Help in Page Views

Discussion in 'PHP' started by ozone1, Jan 18, 2008.

  1. #1
    Hi guys i having problem with page views. i used this code but its not working when i put values manually from the database its showing on the site but its not adding page views to database automatically can anyone tell me what code should i use to make it work. im a newbie in php so it will be gr8 if you give step by step instructions.

    <?php
    $mresult = mysql_query("SELECT * FROM videos WHERE category='".$category."' ORDER BY title ASC");
    while($row = mysql_fetch_array($mresult)) {
    	$id = $row['id'];
    	$title = $row['title'];
    	$numviews = $row['view'];
    	
    	if($numviews<=1) {
    		$viewtime = '<span style="color:#003366;font-style:italic;font-family:arial;">Viewed ' . $numviews . ' Time</span>';
    		} else {
    		$viewtime = '<span style="color:#003366;font-style:italic;font-family:arial;">Viewed ' . $numviews . ' Times</span>';
    	}
    	
    	$letter = substr($title,0,1);
    	$start = $_GET["limit"];
    	
    	if($start=="0-9") {
    		$start="0";
    	} else {
    		$start = $_GET["limit"];
    	}
    	
    	if( ($start==$letter) || (is_numeric($letter) && is_numeric($start)) ) {
    		echo '<tr>';
    	  echo '<td style="padding-left: 10px;"> • &nbsp;';
    	  	if($seo == 0) {
    	    	echo '<a href="' . URL . 'videos.php?id='.$id.'">'.$title.' ('.$viewtime.')</a>'; 
    	    }
    	    if($seo == 1) { 
    	    	echo '<a href="'. URL . 'videos/'.$id.'">'. $title.' ('.$viewtime.')</a><br><img src="'.URL.'templates/imgs/spacer.gif">';
    	    }
    	  echo '</td>';
    	  echo '</tr>';
    	}
    
    Code (markup):
     
    ozone1, Jan 18, 2008 IP