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();

?>

Recommended Answers

All 2 Replies

explain what you need more.

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.