I'm now trying to count a click to get Popular Post Counter from reader, but I get problem with How to count it since previous row has no value or null.
Here's my codes:
<?php
error_reporting(0);
include("conndb.php");
if (isset($_GET['id'])){
$idClick=$_GET['id'];
}
$qryClick = $mydb->prepare("SELECT * FROM ra_articlez WHERE id=:$idClick");
$qryClick->execute();
$varClick = $qryClick->fetchAll();
foreach ($varClick as $echoClick) {
$contID=$echoClick['id'];
$cntentqry=$echoClick['count'];
$imgqry=$echoClick['timestamp'];
$sql="UPDATE ra_articlez SET count=count+1 WHERE id = :idClick";
echo $cntentqry; // can not echo the result
}
?>
Do you have better than it does? please suggest me, thanks.
What are you doing here??
WHERE id=:$idClick
What you want to do is set a bind param and then execute by passing the arguments within the execute()
function.
$qryClick = $mydb->prepare("SELECT * FROM ra_articlez WHERE id=:idClick");
$qryClick->execute(array(':idClick' => $idClick));
You should really read the documentation, because you aren't doing it correctly.
And what exactly are you trying to do in your foreach()
loop?