0

the view_count of the notes table will increment 2 times everytime i click the button that link into this page..

need help desperately.. thanks!

<?php
ob_start();
$note_id=$_GET['note_id'];
include 'fconnect.php';

if ($note_id!=null) {
		$query_ncount = "UPDATE notes SET view_count = (view_count+1) WHERE note_id = '$note_id'";
		$result_ncount = mysql_query($query_ncount);
		if(!$result_ncount ){
			die('invalid query :' .mysql_error());  
		}
	}



$note_result = mysql_query("SELECT * FROM notes WHERE note_id ='$note_id'");


while($row = mysql_fetch_array($note_result))
  {
			$filename = $row['note_name'];
			$file = $row['note_path'];
   }

header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Accept-Ranges: bytes');

@readfile($file);


	
ob_end_flush();

?>
2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by ittanfkh
0

i have a link from another page to this page.. which is as followed:

<td style=" width :7%;"><div align="right" class="read_icon"><a target="_blank" title="Read" href="test.php?note_id=<?php echo $row2['note_id']; ?>"></a></div></td>

once user click the link, it will open the page (the full source code is copied at my 1st post).. there will be 2 things that this page will do..

1. It will increment the notes table's 'view_count' row to 1..
2. it will read the pdf file..

the 2nd function function well.. but the 1st seems to run twice because each time it is click, the value increment 2 times..

can help to identify where's da error?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.