2012-07-07 00:50
浏览 16

PHP - 在页面加载上执行PHP脚本? [关闭]

I want PHP script which counts how many times an item has been bought, increasing the counter by one every time the PHP script (of the purchase) has been executed, and showing it in the page database.

Let's say, when the user is redirected back to the site via Paypal they load the page thankyou.php which on load, increases the database value (of the counter) in a table by one.

I couldn't find any examples so I'm hoping you kind guys here could help me out.

图片转代码服务由CSDN问答提供 功能建议

我想要PHP脚本来计算项目被购买的次数,每次PHP增加一个计数器 脚本(购买)已经执行,并在页面数据库中显示。

让我们说,当用户通过Paypal重定向回网站时,他们加载页面thankyou.php 在加载时,将表中的数据库值(计数器)增加一个。

我找不到任何示例,所以我希望你们这里有点帮助我的人 。

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • drwn65609 2012-07-07 00:54

    php is server side language that is executed on sever side before the page loads. in your case you have to make ajax call to trigger the php code.

    Update: mysql_query("UPDATE table_name SET id = id + 1 WHERE id = '$id'");
    解决 无用
    打赏 举报
  • dongzhengzhong1282 2012-07-07 01:00

    You do not need to increment the value in PHP, you can do it in your query directly in your query:

    UPDATE hits_log SET hits = hits+1 WHERE page = *somthing*

    This can be executed using php's MySQLi library, or similar.

    解决 无用
    打赏 举报

相关推荐 更多相似问题