douhuang3833 2015-03-04 03:11
浏览 30
已采纳

如何在PDO中使用$ _GET计算空行

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.

  • 写回答

1条回答 默认 最新

  • doupao5296 2015-03-04 03:14
    关注

    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?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化